From 018b238e7aac5b4a990a28f49323b821246c9f66 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 27 Apr 2017 01:16:45 -0400 Subject: Decorator doesn't work properly with --all-tests, use runtime check. --- unit-tests.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/unit-tests.py b/unit-tests.py index 10aa810..f0f5fb2 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -132,6 +132,10 @@ class TestCase(unittest.TestCase): self.endTime = datetime.datetime.now() super(TestCase, self).tearDown() + def skipUnlessAll(self, reason): + if not args.all_tests: + self.skipTest(reason) + class TextTestResult(unittest.TextTestResult): def addSuccess(self, test): @@ -197,15 +201,12 @@ class TestPIN(TestCase): self.assertRaises(HAL_ERROR_FORBIDDEN, hsm.is_logged_in, user2) hsm.logout() - @unittest.skipUnless(args.all_tests, "Slow") def test_login_wheel(self): self.login_logout(HAL_USER_WHEEL) - @unittest.skipUnless(args.all_tests, "Slow") def test_login_so(self): self.login_logout(HAL_USER_SO) - @unittest.skipUnless(args.all_tests, "Slow") def test_login_user(self): self.login_logout(HAL_USER_NORMAL) @@ -292,18 +293,19 @@ class TestPKeyGen(TestCaseLoggedIn): def test_gen_sign_verify_rsa_1024_sha256(self): self.gen_sign_verify_rsa(HAL_DIGEST_ALGORITHM_SHA256, 1024) - @unittest.skipUnless(args.all_tests, "Slow") def test_gen_sign_verify_rsa_2048_sha384(self): + self.skipUnlessAll("Slow") self.gen_sign_verify_rsa(HAL_DIGEST_ALGORITHM_SHA384, 2048) - @unittest.skipUnless(args.all_tests, "Hideously slow") def test_gen_sign_verify_rsa_4096_sha512(self): + self.skipUnlessAll("Hideously slow") self.gen_sign_verify_rsa(HAL_DIGEST_ALGORITHM_SHA512, 4096) def test_gen_unsupported_length(self): with self.assertRaises(HAL_ERROR_BAD_ARGUMENTS): hsm.pkey_generate_rsa(1028).delete() + class TestPKeyHashing(TestCaseLoggedIn): """ Tests involving various ways of doing the hashing for public key operations. -- cgit v1.2.3