@@ -21,13 +21,13 @@ class TestNetworksSettings:
2121 def clean_settings (self ):
2222 # Load the setting files in cwd and home, saved them in a temp file
2323 if cwd_network .is_file () and cwd_network .is_file ():
24- orig_cwd_network = NamedTemporaryFile (suffix = ".json" , mode = "w" , delete_on_close = False ).__enter__ ()
24+ orig_cwd_network = NamedTemporaryFile (suffix = ".json" , mode = "w" , delete = False ).__enter__ ()
2525 shutil .copyfile (cwd_network , orig_cwd_network .name )
2626 cwd_network .unlink ()
2727 else :
2828 orig_cwd_network = None
2929 if home_network .is_file () and home_network .is_file ():
30- orig_home_network = NamedTemporaryFile (suffix = ".json" , mode = "w" , delete_on_close = False ).__enter__ ()
30+ orig_home_network = NamedTemporaryFile (suffix = ".json" , mode = "w" , delete = False ).__enter__ ()
3131 shutil .copyfile (home_network , orig_home_network .name )
3232 home_network .unlink ()
3333 else :
@@ -39,10 +39,12 @@ def clean_settings(self):
3939 cwd_network .touch ()
4040 shutil .copyfile (orig_cwd_network .name , cwd_network )
4141 orig_cwd_network .__exit__ (None , None , None )
42+ Path (orig_cwd_network .name ).unlink ()
4243 if orig_home_network is not None :
4344 home_network .touch ()
4445 shutil .copyfile (orig_home_network .name , home_network )
4546 orig_home_network .__exit__ (None , None , None )
47+ Path (orig_home_network .name ).unlink ()
4648
4749 files_to_check = [cwd_network , home_network ]
4850 for file in files_to_check :
@@ -243,27 +245,29 @@ def test_serialize_network_config(self, reset_net_cfg):
243245
244246 expected_network_config = TestNetworksSettings ._build_expected_config (alice_ports , bob_ports )
245247
246- with NamedTemporaryFile (mode = "wt" , delete_on_close = False ) as temp_file :
248+ with NamedTemporaryFile (mode = "wt" , delete = False ) as temp_file :
247249 network_config .write_to_file (temp_file .name )
248250 temp_file .flush ()
249251
250252 serialized_content = Path (temp_file .name ).read_text ()
251253 assert serialized_content == expected_network_config
254+ Path (temp_file .name ).unlink ()
252255
253256 def test_deserialize_network_config (self , reset_net_cfg ):
254257 raw_config = TestNetworksSettings ._build_expected_config ([8020 , 8021 , 8022 ], [8050 , 8051 , 8052 ])
255- with NamedTemporaryFile (mode = "wt" , delete_on_close = False ) as temp_file :
258+ with NamedTemporaryFile (mode = "wt" , delete = False ) as temp_file :
256259 temp_file .write (raw_config )
257260 temp_file .flush ()
258261
259262 network_config .read_from_file (temp_file .name )
260263 assert json .dumps (JSONSerializer .serialize (network_config ), indent = 4 ) == raw_config
264+ Path (temp_file .name ).unlink ()
261265
262266 def test_load_old_json_format (self ):
263267 this_file_folder = Path (__file__ ).parent
264268 old_json_config_path = this_file_folder / "resources" / "old_format.json"
265269
266- with NamedTemporaryFile (mode = "wt" , delete_on_close = False ) as temp_file :
270+ with NamedTemporaryFile (mode = "wt" , delete = False ) as temp_file :
267271 # We copy the content of the resource into a temp file, so we don't
268272 # overwrite the resource for future test sessions
269273 shutil .copy (old_json_config_path , temp_file .name )
@@ -294,3 +298,4 @@ def test_load_old_json_format(self):
294298 assert network_config .nodes [1 ].qnodeos_port == 8832
295299 assert network_config .nodes [1 ].vnode_hostname == "localhost"
296300 assert network_config .nodes [1 ].vnode_port == 8833
301+ Path (temp_file .name ).unlink ()
0 commit comments