From 825493299896cd34e4f4188805c254667e68c077 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 28 Jun 2018 13:53:37 -0400 Subject: Use unittest.TestCase.assertEqual() properly, and crank up test verbosity. --- aes_keywrap.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) mode change 100644 => 100755 aes_keywrap.py diff --git a/aes_keywrap.py b/aes_keywrap.py old mode 100644 new mode 100755 index bb6968a..a026518 --- a/aes_keywrap.py +++ b/aes_keywrap.py @@ -144,8 +144,7 @@ if __name__ == "__main__": K = AESKeyWrapWithPadding(self.hex2bin("00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f")) C = K.wrap_key(I) O = K.unwrap_key(C) - if I != O: - raise RuntimeError("Input and output plaintext did not match: {!r} <> {!r}".format(I, O)) + self.assertEqual(I, O, "Input and output plaintext did not match: {!r} <> {!r}".format(I, O)) def rfc5649_test(self, K, Q, C): K = AESKeyWrapWithPadding(key = self.hex2bin(K)) @@ -153,10 +152,8 @@ if __name__ == "__main__": C = self.hex2bin(C) c = K.wrap_key(Q) q = K.unwrap_key(C) - if q != Q: - raise RuntimeError("Input and output plaintext did not match: {} <> {}".format(self.bin2hex(Q), self.bin2hex(q))) - if c != C: - raise RuntimeError("Input and output ciphertext did not match: {} <> {}".format(self.bin2hex(C), self.bin2hex(c))) + self.assertEqual(q, Q, "Input and output plaintext did not match: {} <> {}".format(self.bin2hex(Q), self.bin2hex(q))) + self.assertEqual(c, C, "Input and output ciphertext did not match: {} <> {}".format(self.bin2hex(C), self.bin2hex(c))) def test_rfc5649_1(self): self.rfc5649_test(K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8", @@ -213,4 +210,4 @@ if __name__ == "__main__": def test_loopback_9(self): self.loopback_test("Hello! My name is Inigo Montoya. You killed my AES key wrapper. Prepare to die.") - unittest.main() + unittest.main(verbosity = 9) -- cgit v1.2.3