@@ -133,8 +133,10 @@ class _06_load_json_argv_with_data_via_localhost_8000_in_setup_teardown(_03_load
133133
134134 # CAREFUL : localhost not always recognized, better to use 127.0.0.1
135135 # Port 0 can also be used and means to select an arbitrary unused port
136- HOST , PORT = "127.0.0.1" , 8000
137- server_adr = f"http://{ HOST } :{ PORT } /"
136+ # HOST, PORT = "127.0.0.1", 8000
137+ # server_adr = f"http://{HOST}:{PORT}/"
138+ HOST , PORT = "127.0.0.1" , 0
139+ server_adr = ''
138140 # Open a HTTP server to access to the current directory
139141 Handler = http .server .SimpleHTTPRequestHandler
140142 httpd = None
@@ -147,6 +149,10 @@ def setUp(self) -> None:
147149 # Exit the server thread when the main thread terminates
148150 server_thread .daemon = True
149151 server_thread .start ()
152+ self .httpd_address , self .httpd_port = self .httpd .server_address
153+ self .httpd_url = f"http://{ self .httpd_address } :{ self .httpd_port } "
154+ print (f"Server URL = { self .httpd_url } " )
155+ self .server_adr = f"http://{ self .httpd_address } :{ self .httpd_port } /"
150156 print (f"\n \n Connection to { self .server_adr } in { server_thread .name } " , end = ' ' )
151157
152158 def tearDown (self ) -> None :
@@ -204,11 +210,14 @@ def HTTPServer_Disconnection(self):
204210class _08_load_json_argv_with_data_via_localhost_8000_in_setupClass_teardownClass (_03_load_json_argv_with_file_in_folder ):
205211 # CAREFUL : localhost not always recognized, better to use 127.0.0.1
206212 # Port 0 can also be used and means to select an arbitrary unused port
207- HOST , PORT = "127.0.0.1" , 8000
208- server_adr = f"http://{ HOST } :{ PORT } /"
213+ # HOST, PORT = "127.0.0.1", 8000
214+ # server_adr = f"http://{HOST}:{PORT}/"
215+ HOST , PORT = "127.0.0.1" , 0
216+ server_adr = ''
209217 # Open a HTTP server to access to the current directory
210218 Handler = http .server .SimpleHTTPRequestHandler
211219 httpd = None
220+ httpd_address , httpd_port = '' , 0
212221
213222 @classmethod
214223 def setUpClass (cls ) -> None :
@@ -219,6 +228,10 @@ def setUpClass(cls) -> None:
219228 # Exit the server thread when the main thread terminates
220229 server_thread .daemon = True
221230 server_thread .start ()
231+ cls .httpd_address , cls .httpd_port = cls .httpd .server_address
232+ cls .httpd_url = f"http://{ cls .httpd_address } :{ cls .httpd_port } "
233+ print (f"Server URL = { cls .httpd_url } " )
234+ cls .server_adr = f"http://{ cls .httpd_address } :{ cls .httpd_port } /"
222235 print (f"\n \n Connection to { cls .server_adr } in { server_thread .name } " , end = ' ' )
223236
224237 @classmethod
0 commit comments