from . import template
from . import log
from . import vars # pylint: disable=redefined-builtin
-from . import hypothesis
+
+# isctest.hypothesis is intentionally NOT imported, because it detects proper
+# hypothesis support and instructs pytest to skip the tests otherwise. It
+# should be manually imported only in the modules that require hypothesis.
# isctest.mark module is intentionally NOT imported, because it relies on
# environment variables which might not be set at the time of import of the
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-try:
- import hypothesis as _
-except ImportError:
- pass
-else:
- from . import settings
- from . import strategies
+# This ensures we're using a suitable hypothesis version. A newer version is
+# required for FIPS-enabled platforms.
+
+import hashlib
+
+import pytest
+
+MIN_HYPOTHESIS_VERSION = None
+
+if "md5" not in hashlib.algorithms_available:
+ # FIPS mode is enabled, use hypothesis 4.41.2 which doesn't use md5
+ MIN_HYPOTHESIS_VERSION = "4.41.2"
+
+pytest.importorskip("hypothesis", minversion=MIN_HYPOTHESIS_VERSION)
+
+from . import settings
+from . import strategies
pytest.importorskip("dns", minversion="2.7.0") # TSIG parsing without validation
-# in FIPs mode md5 fails so we need 4.41.2 or later which does not use md5
-try:
- import hashlib
-
- hashlib.md5(b"1234")
- pytest.importorskip("hypothesis")
-except ValueError:
- pytest.importorskip("hypothesis", minversion="4.41.2")
-
import dns.exception
import dns.message
import dns.name
import dns.rrset
import dns.tsig
-from hypothesis import assume, example, given
-from hypothesis.strategies import binary, booleans, composite, just, sampled_from
-
import isctest
from isctest.hypothesis.strategies import dns_names, uint
+from hypothesis import assume, example, given
+from hypothesis.strategies import binary, booleans, composite, just, sampled_from
+
pytestmark = pytest.mark.extra_artifacts(
[
import dns.rdatatype
import dns.rrset
-# in FIPs mode md5 fails so we need 4.41.2 or later which does not use md5
-try:
- import hashlib
-
- hashlib.md5(b"1234")
- pytest.importorskip("hypothesis")
-except ValueError:
- pytest.importorskip("hypothesis", minversion="4.41.2")
+from isctest.hypothesis.strategies import dns_names, dns_rdatatypes_without_meta
from hypothesis import assume, example, given, settings
-from isctest.hypothesis.strategies import dns_names, dns_rdatatypes_without_meta
import isctest.check
import isctest.name
import isctest.query