`isctest.hypothesis` seems to be a nice place to have these.
from . import run
from . import log
from . import vars # pylint: disable=redefined-builtin
+from . import 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
--- /dev/null
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from . import settings
+from . import strategies
--- /dev/null
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+import os
+
+from hypothesis import settings
+
+# Timing of hypothesis tests is flaky in the CI, so we disable deadlines.
+settings.register_profile("ci", deadline=None)
+settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))
import dns.rdataclass
import dns.rdatatype
-# LATER: Move this file so it can be easily reused.
-
@composite
def dns_names(
RDATACLASS_MAX = RDATATYPE_MAX = 65535
-dns_rdataclasses = builds(dns.rdataclass.RdataClass, integers(0, RDATACLASS_MAX))
+try:
+ dns_rdataclasses = builds(dns.rdataclass.RdataClass, integers(0, RDATACLASS_MAX))
+ dns_rdatatypes = builds(dns.rdatatype.RdataType, integers(0, RDATATYPE_MAX))
+except AttributeError:
+ # In old dnspython versions, RDataTypes and RDataClasses are int and not enums.
+ dns_rdataclasses = integers(0, RDATACLASS_MAX) # type: ignore
+ dns_rdatatypes = integers(0, RDATATYPE_MAX) # type: ignore
dns_rdataclasses_without_meta = dns_rdataclasses.filter(dns.rdataclass.is_metaclass)
-dns_rdatatypes = builds(dns.rdatatype.RdataType, integers(0, RDATATYPE_MAX))
# NOTE: This should really be `dns_rdatatypes_without_meta = dns_rdatatypes_without_meta.filter(dns.rdatatype.is_metatype()`,
# but hypothesis then complains about the filter being too strict, so it is done in a “constructive” way.
- special behavior of rdtypes like CNAME
"""
-import os
import pytest
pytest.importorskip("dns", minversion="2.0.0")
pytest.importorskip("hypothesis")
except ValueError:
pytest.importorskip("hypothesis", minversion="4.41.2")
-from hypothesis import assume, example, given, settings
+from hypothesis import assume, example, given
-from strategies import dns_names, dns_rdatatypes_without_meta
+from isctest.hypothesis.strategies import dns_names, dns_rdatatypes_without_meta
import isctest.check
import isctest.name
import isctest.query
IP_ADDR = "10.53.0.1"
TIMEOUT = 5 # seconds, just a sanity check
-# Timing of hypothesis tests is flaky in the CI, so we disable deadlines.
-settings.register_profile("ci", deadline=None)
-settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))
-
@given(name=dns_names(suffix=SUFFIX), rdtype=dns_rdatatypes_without_meta)
def test_wildcard_rdtype_mismatch(