bpo-40637: Do not emit warnings for disabled builtin hashes (GH-20937)

test_hashlib emits some warnings when it cannot find some hashes
as it assumes they failed to compile. Since we can disable hashes
through configure, we emit the warnings only in the case that we
did not intentionaly disable them.

Automerge-Triggered-By: @tiran
This commit is contained in:
stratakis 2020-06-17 19:26:08 +02:00 committed by GitHub
parent 98ce7b107e
commit 236a0f5cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,7 +103,7 @@ class HashLibTestCase(unittest.TestCase):
try:
return importlib.import_module(module_name)
except ModuleNotFoundError as error:
if self._warn_on_extension_import:
if self._warn_on_extension_import and module_name in builtin_hashes:
warnings.warn('Did a C extension fail to compile? %s' % error)
return None