From b7d86eca36d03377aad9c1fb02cdc9b8917bf22b Mon Sep 17 00:00:00 2001 From: vladdd Date: Wed, 11 Sep 2013 12:36:44 -0400 Subject: [PATCH] Fix unit test failure in test_roledb.py Ensure roledb is empty prior to running the test cases. roledb.py may have been modified by other unit tests that did not properly clean up. --- tests/unit/test_roledb.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_roledb.py b/tests/unit/test_roledb.py index 6d068054..baecab91 100755 --- a/tests/unit/test_roledb.py +++ b/tests/unit/test_roledb.py @@ -38,7 +38,7 @@ class TestRoledb(unittest.TestCase): def setUp(self): - pass + pass @@ -403,6 +403,21 @@ def _test_rolename(self, test_function): +def setUpModule(): + # setUpModule is called before any test cases run. + # Ensure the roledb has not been modified by a previous test, which may + # affect assumptions (i.e., empty roledb) made by the tests cases in this + # unit test. + tuf.roledb.clear_roledb() + +def tearDownModule(): + # tearDownModule is called after all the tests have run. + # Ensure we clean up roledb. Courtesy is contagious, and it begins with + # test_roledb.py. + tuf.roledb.clear_roledb() + + + # Run the unit tests. if __name__ == '__main__': unittest.main()