Make sure that the warnings filter is not reset or changed beyond the current
running test file.
Closes issue2407. Thanks Jerry Seutter.
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 6c18715..c57ac7f 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -211,8 +211,8 @@
def digest(self):
return self._x.digest()
- warnings.simplefilter('error', RuntimeWarning)
- try:
+ with test_support.catch_warning():
+ warnings.simplefilter('error', RuntimeWarning)
try:
hmac.HMAC('a', 'b', digestmod=MockCrazyHash)
except RuntimeWarning:
@@ -227,8 +227,6 @@
pass
else:
self.fail('Expected warning about small block_size')
- finally:
- warnings.resetwarnings()