From ad9c82409dc49f02fde2c0f0bd36b4b6c100e66d Mon Sep 17 00:00:00 2001 From: Martin Vrachev Date: Fri, 6 Nov 2020 16:40:46 +0200 Subject: [PATCH] Tests: Remove "temp file" from comments Update the comments to not mention the usage of temp file for logging regarding the instances of the TestServerProcess class. Also, remove one unused import. Signed-off-by: Martin Vrachev --- tests/test_arbitrary_package_attack.py | 2 +- tests/test_download.py | 6 ++---- tests/test_endless_data_attack.py | 2 +- tests/test_extraneous_dependencies_attack.py | 2 +- tests/test_indefinite_freeze_attack.py | 2 +- tests/test_key_revocation_integration.py | 2 +- tests/test_mix_and_match_attack.py | 2 +- .../test_multiple_repositories_integration.py | 7 +++---- tests/test_replay_attack.py | 2 +- tests/test_slow_retrieval_attack.py | 4 +--- tests/test_updater.py | 21 +++++++++---------- .../test_updater_root_rotation_integration.py | 2 +- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/tests/test_arbitrary_package_attack.py b/tests/test_arbitrary_package_attack.py index 1b49a729..80ea48fa 100755 --- a/tests/test_arbitrary_package_attack.py +++ b/tests/test_arbitrary_package_attack.py @@ -82,7 +82,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_download.py b/tests/test_download.py index 1107442c..af13128e 100755 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -90,8 +90,7 @@ def setUp(self): def tearDown(self): unittest_toolbox.Modified_TestCase.tearDown(self) - # Logs stdout and stderr from the server subprocess and then it - # kills it and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). self.server_process_handler.clean() self.target_fileobj.close() @@ -367,8 +366,7 @@ def test_https_connection(self): bad_https_server_handler, expd_https_server_handler]: - # Logs stdout and stderr from the server subprocess and then it - # kills it and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). proc_handler.clean() diff --git a/tests/test_endless_data_attack.py b/tests/test_endless_data_attack.py index 34928a93..18bb5215 100755 --- a/tests/test_endless_data_attack.py +++ b/tests/test_endless_data_attack.py @@ -84,7 +84,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_extraneous_dependencies_attack.py b/tests/test_extraneous_dependencies_attack.py index c945d7bc..55e20158 100755 --- a/tests/test_extraneous_dependencies_attack.py +++ b/tests/test_extraneous_dependencies_attack.py @@ -88,7 +88,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_indefinite_freeze_attack.py b/tests/test_indefinite_freeze_attack.py index 9202a541..84819b74 100755 --- a/tests/test_indefinite_freeze_attack.py +++ b/tests/test_indefinite_freeze_attack.py @@ -102,7 +102,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_key_revocation_integration.py b/tests/test_key_revocation_integration.py index 420a4f1d..38584133 100755 --- a/tests/test_key_revocation_integration.py +++ b/tests/test_key_revocation_integration.py @@ -83,7 +83,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_mix_and_match_attack.py b/tests/test_mix_and_match_attack.py index 26b8f77c..61d5c7cb 100755 --- a/tests/test_mix_and_match_attack.py +++ b/tests/test_mix_and_match_attack.py @@ -87,7 +87,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_multiple_repositories_integration.py b/tests/test_multiple_repositories_integration.py index 0d5bd3f6..211d1a5f 100755 --- a/tests/test_multiple_repositories_integration.py +++ b/tests/test_multiple_repositories_integration.py @@ -124,13 +124,13 @@ def setUp(self): # has been changed when executing a subprocess. SIMPLE_SERVER_PATH = os.path.join(os.getcwd(), 'simple_server.py') - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. self.server_process_handler = utils.TestServerProcess(log=logger, server=SIMPLE_SERVER_PATH, popen_cwd=self.repository_directory) logger.debug('Server process started.') - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. self.server_process_handler2 = utils.TestServerProcess(log=logger, server=SIMPLE_SERVER_PATH, popen_cwd=self.repository_directory2) @@ -160,8 +160,7 @@ def tearDown(self): # directories that may have been created during each test case. unittest_toolbox.Modified_TestCase.tearDown(self) - # Logs stdout and stderr from the server subprocesses and then it - # kills them and closes the temp files used for logging. + # Cleans the resources and flush the logged lines (if any). self.server_process_handler.clean() self.server_process_handler2.clean() diff --git a/tests/test_replay_attack.py b/tests/test_replay_attack.py index 0658babd..2a22809b 100755 --- a/tests/test_replay_attack.py +++ b/tests/test_replay_attack.py @@ -87,7 +87,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_slow_retrieval_attack.py b/tests/test_slow_retrieval_attack.py index 4b9943bf..db2e1b35 100755 --- a/tests/test_slow_retrieval_attack.py +++ b/tests/test_slow_retrieval_attack.py @@ -46,7 +46,6 @@ import os import tempfile -import time import shutil import logging import unittest @@ -196,8 +195,7 @@ def tearDown(self): tuf.roledb.clear_roledb(clear_all=True) tuf.keydb.clear_keydb(clear_all=True) - # Logs stdout and stderr from the server subprocess and then it - # kills it and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). self.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the diff --git a/tests/test_updater.py b/tests/test_updater.py index a14aae53..f2665b78 100755 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -108,7 +108,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the @@ -1082,7 +1082,7 @@ def test_6_get_one_valid_targetinfo(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. server_process_handler = utils.TestServerProcess(log=logger, server=self.SIMPLE_SERVER_PATH) @@ -1206,7 +1206,7 @@ def test_6_get_one_valid_targetinfo(self): self.repository_updater.get_one_valid_targetinfo, '/foo/foo1.1.tar.gz') - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). server_process_handler.clean() @@ -1376,7 +1376,7 @@ def test_7_updated_targets(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. server_process_handler = utils.TestServerProcess(log=logger, server=self.SIMPLE_SERVER_PATH) @@ -1491,7 +1491,7 @@ def test_7_updated_targets(self): self.repository_updater.updated_targets(all_targets, destination_directory) self.assertEqual(len(updated_targets), 1) - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). server_process_handler.clean() @@ -1503,7 +1503,7 @@ def test_8_remove_obsolete_targets(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. server_process_handler = utils.TestServerProcess(log=logger, server=self.SIMPLE_SERVER_PATH) @@ -1594,7 +1594,7 @@ def test_8_remove_obsolete_targets(self): del self.repository_updater.metadata['previous']['targets'] self.repository_updater.remove_obsolete_targets(destination_directory) - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). server_process_handler.clean() @@ -1864,13 +1864,13 @@ def setUp(self): # as a delegated role 'targets/role1', three target files, five key files, # etc. - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. self.server_process_handler = utils.TestServerProcess(log=logger, server=self.SIMPLE_SERVER_PATH, popen_cwd=self.repository_directory) logger.debug('Server process started.') - # Creates a subprocess running server and uses temp file for logging. + # Creates a subprocess running a server. self.server_process_handler2 = utils.TestServerProcess(log=logger, server=self.SIMPLE_SERVER_PATH, popen_cwd=self.repository_directory2) @@ -1923,8 +1923,7 @@ def tearDown(self): # directories that may have been created during each test case. unittest_toolbox.Modified_TestCase.tearDown(self) - # Logs stdout and stderr from the server subprocesses and then it - # kills them and closes the temp files used for logging. + # Cleans the resources and flush the logged lines (if any). self.server_process_handler.clean() self.server_process_handler2.clean() diff --git a/tests/test_updater_root_rotation_integration.py b/tests/test_updater_root_rotation_integration.py index 04ddc731..b1b83ba2 100755 --- a/tests/test_updater_root_rotation_integration.py +++ b/tests/test_updater_root_rotation_integration.py @@ -91,7 +91,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # Kills the server subprocess and closes the temp file used for logging. + # Cleans the resources and flush the logged lines (if any). cls.server_process_handler.clean() # Remove the temporary repository directory, which should contain all the