The intended purpose of the @pytest.mark.dnspython{,2} decorators was to
cause dnspython-based tests to be skipped if dnspython is not available
(or not recent enough). However, a number of system tests employing
those decorators contain global "import dns.resolver" statements which
trigger ImportError exceptions during test initialization if dnspython
is not available. In other words, the @pytest.mark.dnspython{,2}
decorators serve no useful purpose.
Currently, whenever a Python-based test requires dnspython, that
requirement applies to all tests in a given *.py file. Given that,
employ global pytest.importorskip() calls to ensure dnspython-based
parts of various system tests are skipped when dnspython is not
available. Remove all occurrences of the @pytest.mark.dnspython{,2}
decorators (and all associated code) to prevent confusion.
(cherry picked from commit
05c97f2329309506060e29c2935739aed6a815dd)
+++ /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 pytest
-
-
-def pytest_configure(config):
- config.addinivalue_line(
- "markers", "dnspython: mark tests that need dnspython to function"
- )
- config.addinivalue_line(
- "markers", "dnspython2: mark tests that need dnspython >= 2.0.0"
- )
-
-
-def pytest_collection_modifyitems(config, items):
- # pylint: disable=unused-argument,unused-import,too-many-branches
- # pylint: disable=import-outside-toplevel
-
- # Test for dnspython module
- skip_dnspython = pytest.mark.skip(
- reason="need dnspython module to run")
- try:
- import dns.query # noqa: F401
- except ModuleNotFoundError:
- for item in items:
- if "dnspython" in item.keywords:
- item.add_marker(skip_dnspython)
-
- # Test for dnspython >= 2.0.0 module
- skip_dnspython2 = pytest.mark.skip(
- reason="need dnspython >= 2.0.0 module to run")
- try:
- from dns.query import udp_with_fallback # noqa: F401
- except ImportError:
- for item in items:
- if "dnspython2" in item.keywords:
- item.add_marker(skip_dnspython2)
import dns.resolver
import pytest
+pytest.importorskip('dns', minversion='2.0.0')
+
def has_signed_apex_nsec(zone, response):
has_nsec = False
assert found
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_checkds_dspublished(named_port):
# We create resolver instances that will be used to send queries.
server = dns.resolver.Resolver()
# TBD: Check with TSIG
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_checkds_dswithdrawn(named_port):
# We create resolver instances that will be used to send queries.
server = dns.resolver.Resolver()
+++ /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 pytest
-
-
-def pytest_configure(config):
- config.addinivalue_line(
- "markers", "dnspython: mark tests that need dnspython to function"
- )
-
-
-def pytest_collection_modifyitems(config, items):
- # pylint: disable=unused-argument,unused-import,too-many-branches
- # pylint: disable=import-outside-toplevel
-
- # Test for dnspython module
- skip_dnspython = pytest.mark.skip(
- reason="need dnspython module to run")
- try:
- import dns.query # noqa: F401
- except ModuleNotFoundError:
- for item in items:
- if "dnspython" in item.keywords:
- item.add_marker(skip_dnspython)
import dns.resolver
import pytest
+pytest.importorskip('dns')
+
def do_work(named_proc, resolver, rndc_cmd, kill_method, n_workers, n_queries):
"""Creates a number of A queries to run in parallel
assert ret_code == 0
-@pytest.mark.dnspython
def test_named_shutdown(named_port, control_port):
# pylint: disable-msg=too-many-locals
cfg_dir = os.path.join(os.getcwd(), "resolver")
def pytest_configure(config):
- config.addinivalue_line(
- "markers", "dnspython: mark tests that need dnspython to function"
- )
- config.addinivalue_line(
- "markers", "dnspython2: mark tests that need dnspython >= 2.0.0"
- )
config.addinivalue_line(
"markers", "long: mark tests that take a long time to run"
)
def pytest_collection_modifyitems(config, items):
# pylint: disable=unused-argument,unused-import,too-many-branches
# pylint: disable=import-outside-toplevel
-
- # Test for dnspython module
- skip_dnspython = pytest.mark.skip(
- reason="need dnspython module to run")
- try:
- import dns.query # noqa: F401
- except ModuleNotFoundError:
- for item in items:
- if "dnspython" in item.keywords:
- item.add_marker(skip_dnspython)
-
- # Test for dnspython >= 2.0.0 module
- skip_dnspython2 = pytest.mark.skip(
- reason="need dnspython >= 2.0.0 module to run")
- try:
- from dns.query import send_tcp # noqa: F401
- except ImportError:
- for item in items:
- if "dnspython2" in item.keywords:
- item.add_marker(skip_dnspython2)
-
skip_long_tests = pytest.mark.skip(
reason="need CI_ENABLE_ALL_TESTS environment variable")
if not os.environ.get("CI_ENABLE_ALL_TESTS"):
import pytest
+pytest.importorskip('dns', minversion='2.0.0')
+
+
TIMEOUT = 10
return time.time() + TIMEOUT
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_initial_timeout(named_port):
#
# The initial timeout is 2.5 seconds, so this should timeout
raise EOFError from e
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_idle_timeout(named_port):
#
# The idle timeout is 5 seconds, so the third message should fail
raise EOFError from e
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_keepalive_timeout(named_port):
#
# Keepalive is 7 seconds, so the third message should succeed.
(response, rtime) = dns.query.receive_tcp(sock, timeout())
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_pipelining_timeout(named_port):
#
# The pipelining should only timeout after the last message is received
raise EOFError from e
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_long_axfr(named_port):
#
# The timers should not fire during AXFR, thus the connection should not
assert soa is not None
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
def test_send_timeout(named_port):
import dns.query
raise EOFError from e
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
@pytest.mark.long
def test_max_transfer_idle_out(named_port):
import dns.query
assert soa is None
-@pytest.mark.dnspython
-@pytest.mark.dnspython2
@pytest.mark.long
def test_max_transfer_time_out(named_port):
import dns.query