summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_hmac.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2020-05-16 23:05:40 (GMT)
committerGitHub <noreply@github.com>2020-05-16 23:05:40 (GMT)
commit837f9e42e3a1ad03b340661afe85e67d2719334f (patch)
tree74280c3ef52a982d51b3337bc3d219722c09390f /Lib/test/test_hmac.py
parentdff92bb31f7db1a80ac431811f8108bd0ef9be43 (diff)
downloadcpython-837f9e42e3a1ad03b340661afe85e67d2719334f.zip
cpython-837f9e42e3a1ad03b340661afe85e67d2719334f.tar.gz
cpython-837f9e42e3a1ad03b340661afe85e67d2719334f.tar.bz2
bpo-40645: Deprecated internal details of hmac.HMAC (GH-20132)
Diffstat (limited to 'Lib/test/test_hmac.py')
-rw-r--r--Lib/test/test_hmac.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 08086f0..1f3ec4c 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -409,11 +409,11 @@ class CopyTestCase(unittest.TestCase):
# Testing if attributes are of same type.
h1 = hmac.HMAC(b"key", digestmod="sha256")
h2 = h1.copy()
- self.assertTrue(h1.digest_cons == h2.digest_cons,
+ self.assertTrue(h1._digest_cons == h2._digest_cons,
"digest constructors don't match.")
- self.assertEqual(type(h1.inner), type(h2.inner),
+ self.assertEqual(type(h1._inner), type(h2._inner),
"Types of inner don't match.")
- self.assertEqual(type(h1.outer), type(h2.outer),
+ self.assertEqual(type(h1._outer), type(h2._outer),
"Types of outer don't match.")
@hashlib_helper.requires_hashdigest('sha256')
@@ -423,10 +423,21 @@ class CopyTestCase(unittest.TestCase):
h2 = h1.copy()
# Using id() in case somebody has overridden __eq__/__ne__.
self.assertTrue(id(h1) != id(h2), "No real copy of the HMAC instance.")
- self.assertTrue(id(h1.inner) != id(h2.inner),
+ self.assertTrue(id(h1._inner) != id(h2._inner),
"No real copy of the attribute 'inner'.")
- self.assertTrue(id(h1.outer) != id(h2.outer),
+ self.assertTrue(id(h1._outer) != id(h2._outer),
"No real copy of the attribute 'outer'.")
+ self.assertEqual(h1._inner, h1.inner)
+ self.assertEqual(h1._outer, h1.outer)
+ self.assertEqual(h1._digest_cons, h1.digest_cons)
+
+ @hashlib_helper.requires_hashdigest('sha256')
+ def test_properties(self):
+ # deprecated properties
+ h1 = hmac.HMAC(b"key", digestmod="sha256")
+ self.assertEqual(h1._inner, h1.inner)
+ self.assertEqual(h1._outer, h1.outer)
+ self.assertEqual(h1._digest_cons, h1.digest_cons)
@hashlib_helper.requires_hashdigest('sha256')
def test_equality(self):