summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2019-10-18 03:30:42 (GMT)
committerGitHub <noreply@github.com>2019-10-18 03:30:42 (GMT)
commitf33c57d5c780da1500619f548585792bb5b750ee (patch)
treed73bb962abdea1b31e27dc01c070a595a4f74fb5 /Lib/test
parentd8ca2354ed30c12b9ce37c4535222b700a727b32 (diff)
downloadcpython-f33c57d5c780da1500619f548585792bb5b750ee.zip
cpython-f33c57d5c780da1500619f548585792bb5b750ee.tar.gz
cpython-f33c57d5c780da1500619f548585792bb5b750ee.tar.bz2
bpo-33604: Raise TypeError on missing hmac arg. (GH-16805)
Also updates the documentation to clarify the situation surrounding the digestmod parameter that is required despite its position in the argument list as of 3.8.0 as well as removing old python2 era references to "binary strings". We indavertently had this raise ValueError in 3.8.0 for the missing arg. This is not considered an API change as no reasonable code would be catching this missing argument error in order to handle it.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_hmac.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 1bbf201..ea00367 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -312,10 +312,15 @@ class TestVectorsTestCase(unittest.TestCase):
self.fail('Expected warning about small block_size')
def test_with_digestmod_no_default(self):
- with self.assertRaises(ValueError):
+ """The digestmod parameter is required as of Python 3.8."""
+ with self.assertRaisesRegex(TypeError, r'required.*digestmod'):
key = b"\x0b" * 16
data = b"Hi There"
hmac.HMAC(key, data, digestmod=None)
+ with self.assertRaisesRegex(TypeError, r'required.*digestmod'):
+ hmac.new(key, data)
+ with self.assertRaisesRegex(TypeError, r'required.*digestmod'):
+ hmac.HMAC(key, msg=data, digestmod='')
class ConstructorTestCase(unittest.TestCase):