mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Tests no longer run automatically when imported.
aggregate_tests now loads all the unit tests into one suite and runs them together, so that any failures and errors show up together in a concise report.
This commit is contained in:
parent
04d96e62f1
commit
2b8d654ceb
18 changed files with 76 additions and 58 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<Author>
|
||||
Konstantin Andrianov
|
||||
Zane Fisher
|
||||
|
||||
<Started>
|
||||
January 26, 2013
|
||||
|
|
@ -12,15 +13,21 @@
|
|||
See LICENSE for licensing information.
|
||||
|
||||
<Purpose>
|
||||
Run all the unit tests in 'tuf/tests'.
|
||||
Run all the unit tests from every .py file beginning with "test_" in 'tuf/tests'.
|
||||
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import glob
|
||||
import tuf.keydb as keydb
|
||||
import tuf.repo.keystore as keystore
|
||||
import tuf.roledb as roledb
|
||||
|
||||
tests_list = glob.glob('test_*.py')
|
||||
for test in tests_list:
|
||||
__import__(test[:-3])
|
||||
|
||||
import system_tests.test_util_test_tools
|
||||
import system_tests.test_replay_attack
|
||||
# Remove '.py' from each filename.
|
||||
tests_list = [test[:-3] for test in tests_list]
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromNames(tests_list)
|
||||
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
|
|
|||
|
|
@ -186,5 +186,5 @@ def test_download_url_to_tempfileobj(self):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestDownload)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -628,5 +628,5 @@ def test_encode_canonical(self):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestFormats)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -225,5 +225,5 @@ def _do_update_file_obj(self, library):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestHash)
|
||||
unittest.TextTestRunner(verbosity=3).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -217,5 +217,5 @@ def test_create_keydb_from_root_metadata(self):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestKeydb)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -321,5 +321,5 @@ def test_internal_decrypt(self):
|
|||
|
||||
|
||||
# Run the unit tests.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestKeystore)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -97,5 +97,5 @@ def test_get_list_of_mirrors(self):
|
|||
|
||||
|
||||
# Run the unittests
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestMirrors)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -165,5 +165,5 @@ def test_expected_behaviour_of_push_with_scp(self):
|
|||
|
||||
|
||||
# Run the unittests
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestPush)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -165,5 +165,5 @@ def test_exceptions_handeling_of_read_config_file(self):
|
|||
|
||||
|
||||
# Run the unittests
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestPushtoolslib)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -191,5 +191,5 @@ def _remove_repository_directories(repo_dir, keystore_dir, client_dir):
|
|||
|
||||
|
||||
# Run the unit tests.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestQuickstart)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ def test_clear_roledb(self):
|
|||
|
||||
def test_add_role(self):
|
||||
# Test conditions where the arguments are valid.
|
||||
print('ROLES: '+str(tuf.roledb._roledb_dict.keys()))
|
||||
self.assertEqual(0, len(tuf.roledb._roledb_dict))
|
||||
rolename = 'targets'
|
||||
roleinfo = {'keyids': ['123'], 'threshold': 1}
|
||||
|
|
@ -396,5 +397,5 @@ def _test_rolename(self, test_function):
|
|||
|
||||
|
||||
# Run the unit tests.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestRoledb)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -180,5 +180,5 @@ def test_verify_signature(self):
|
|||
|
||||
|
||||
# Run the unit tests.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestRsa_key)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -326,5 +326,5 @@ def test_RegularExpression(self):
|
|||
|
||||
|
||||
# Run the unit tests.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestSchema)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -391,5 +391,5 @@ def test_signable_has_invalid_format(self):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestSig)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -1484,9 +1484,12 @@ def _mock_get_keyids(junk):
|
|||
|
||||
|
||||
# Run unit tests.
|
||||
loader = unittest_toolbox.unittest.TestLoader
|
||||
suite = loader().loadTestsFromTestCase(TestSignercli)
|
||||
try:
|
||||
unittest_toolbox.unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
finally:
|
||||
unittest_toolbox.Modified_TestCase.clear_toolbox()
|
||||
#loader = unittest_toolbox.unittest.TestLoader
|
||||
#suite = loader().loadTestsFromTestCase(TestSignercli)
|
||||
#try:
|
||||
# unittest_toolbox.unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
#finally:
|
||||
# unittest_toolbox.Modified_TestCase.clear_toolbox()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -898,9 +898,12 @@ def _get_signed_role_info(self, role, directory=None):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestSignerlib)
|
||||
try:
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
finally:
|
||||
unit_tbox.clear_toolbox()
|
||||
tuf.repo.keystore.clear_keystore()
|
||||
#suite = unittest.TestLoader().loadTestsFromTestCase(TestSignerlib)
|
||||
#try:
|
||||
# unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
#finally:
|
||||
# unit_tbox.clear_toolbox()
|
||||
# tuf.repo.keystore.clear_keystore()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ def test_2__import_delegations(self):
|
|||
|
||||
# Verify that there was no change in roledb and keydb dictionaries
|
||||
# by checking the number of elements in the dictionaries.
|
||||
self.assertEqual(len(roledb._roledb_dict), 5)
|
||||
self.assertEqual(len(roledb._roledb_dict), 5)
|
||||
self.assertEqual(len(keydb._keydb_dict), 5)
|
||||
|
||||
# Test: normal case, first level delegation.
|
||||
|
|
@ -1142,18 +1142,22 @@ def test_8_remove_obsolete_targets(self):
|
|||
|
||||
|
||||
# Run all unit tests.
|
||||
loader = unittest_toolbox.unittest.TestLoader()
|
||||
suite = unittest_toolbox.unittest.TestSuite()
|
||||
#loader = unittest_toolbox.unittest.TestLoader()
|
||||
#suite = unittest_toolbox.unittest.TestSuite()
|
||||
|
||||
class1_tests = loader.loadTestsFromTestCase(TestUpdater_init_)
|
||||
class2_tests = loader.loadTestsFromTestCase(TestUpdater)
|
||||
#class1_tests = loader.loadTestsFromTestCase(TestUpdater_init_)
|
||||
#class2_tests = loader.loadTestsFromTestCase(TestUpdater)
|
||||
|
||||
suite.addTest(class1_tests)
|
||||
suite.addTest(class2_tests)
|
||||
#suite.addTest(class1_tests)
|
||||
#suite.addTest(class2_tests)
|
||||
|
||||
try:
|
||||
unittest_toolbox.unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
finally:
|
||||
# Removing repositories.
|
||||
setup.remove_all_repositories(TestUpdater.repositories['main_repository'])
|
||||
unittest_toolbox.Modified_TestCase.clear_toolbox()
|
||||
#try:
|
||||
# unittest_toolbox.unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
#finally:
|
||||
# # Removing repositories.
|
||||
# setup.remove_all_repositories(TestUpdater.repositories['main_repository'])
|
||||
# unittest_toolbox.Modified_TestCase.clear_toolbox()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -302,5 +302,5 @@ def test_B6_load_json_file(self):
|
|||
|
||||
|
||||
# Run unit test.
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestUtil)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue