From d015707e0e26bafbfad72511c0a47cbb66c90971 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 10 Jun 2020 15:38:05 -0400 Subject: Fix remaining Python 3 unit test string encoding bug Really just one bug, but confusingly masked by an interaction between generators and our XDR context manager, so don't use the context manager in the one generator method in the cryptech.libhal API. Also run reindent.py on a few old test modules. --- unit-tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'unit-tests.py') diff --git a/unit-tests.py b/unit-tests.py index fab09e8..b1e8a21 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -1227,7 +1227,6 @@ class TestPKeyMatch(TestCaseLoggedIn): with hsm.pkey_load(obj.der, flags) as k: self.addCleanup(self.cleanup_key, k.uuid) uuids.add(k.uuid) - #print k.uuid, k.key_type, k.key_curve, self.key_flag_names(k.key_flags) k.set_attributes(dict((i, a) for i, a in enumerate((str(obj.keytype), str(obj.fn2))))) return uuids @@ -1256,14 +1255,14 @@ class TestPKeyMatch(TestCaseLoggedIn): n = 0 for n, k in self.match(mask = mask, flags = flags, uuids = uuids, type = keytype): self.assertEqual(k.key_type, keytype) - self.assertEqual(k.get_attributes({0}).pop(0), bytes(keytype)) + self.assertEqual(k.get_attributes({0}).pop(0).decode(), str(keytype)) self.assertEqual(n, sum(1 for t1, t2 in tags if t1 == keytype)) for curve in set(HALCurve.index.values()) - {HAL_CURVE_NONE}: n = 0 for n, k in self.match(mask = mask, flags = flags, uuids = uuids, curve = curve): self.assertEqual(k.key_curve, curve) - self.assertEqual(k.get_attributes({1}).pop(1), str(curve)) + self.assertEqual(k.get_attributes({1}).pop(1).decode(), str(curve)) self.assertIn(k.key_type, (HAL_KEY_TYPE_EC_PUBLIC, HAL_KEY_TYPE_EC_PRIVATE)) self.assertEqual(n, sum(1 for t1, t2 in tags if t2 == curve)) -- cgit v1.2.3