mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Extract dns.rcode compatibility code to isctest.compat
(cherry picked from commit 8b55d0709db7d9aec8587e29c11c2b7591d170f4)
This commit is contained in:
parent
c8c8b36e44
commit
944fc02f83
@ -10,23 +10,14 @@
|
||||
# information regarding copyright ownership.
|
||||
|
||||
import shutil
|
||||
from typing import Any, Optional
|
||||
from typing import Optional
|
||||
|
||||
import dns.rcode
|
||||
import dns.message
|
||||
import dns.zone
|
||||
|
||||
import isctest.log
|
||||
|
||||
# compatiblity with dnspython<2.0.0
|
||||
try:
|
||||
# In dnspython>=2.0.0, dns.rcode.Rcode class is available
|
||||
# pylint: disable=invalid-name
|
||||
dns_rcode = dns.rcode.Rcode # type: Any
|
||||
except AttributeError:
|
||||
# In dnspython<2.0.0, selected rcodes are available as integers directly
|
||||
# from dns.rcode
|
||||
dns_rcode = dns.rcode
|
||||
from isctest.compat import dns_rcode
|
||||
|
||||
|
||||
def rcode(message: dns.message.Message, expected_rcode) -> None:
|
||||
|
24
bin/tests/system/isctest/compat.py
Normal file
24
bin/tests/system/isctest/compat.py
Normal file
@ -0,0 +1,24 @@
|
||||
# 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 typing import Any
|
||||
|
||||
import dns.rcode
|
||||
|
||||
# compatiblity with dnspython<2.0.0
|
||||
try:
|
||||
# In dnspython>=2.0.0, dns.rcode.Rcode class is available
|
||||
# pylint: disable=invalid-name
|
||||
dns_rcode = dns.rcode.Rcode # type: Any
|
||||
except AttributeError:
|
||||
# In dnspython<2.0.0, selected rcodes are available as integers directly
|
||||
# from dns.rcode
|
||||
dns_rcode = dns.rcode
|
@ -17,16 +17,7 @@ import dns.query
|
||||
import dns.message
|
||||
|
||||
import isctest.log
|
||||
|
||||
# compatiblity with dnspython<2.0.0
|
||||
try:
|
||||
# In dnspython>=2.0.0, dns.rcode.Rcode class is available
|
||||
# pylint: disable=invalid-name
|
||||
dns_rcode = dns.rcode.Rcode # type: Any
|
||||
except AttributeError:
|
||||
# In dnspython<2.0.0, selected rcodes are available as integers directly
|
||||
# from dns.rcode
|
||||
dns_rcode = dns.rcode
|
||||
from isctest.compat import dns_rcode
|
||||
|
||||
QUERY_TIMEOUT = 10
|
||||
|
||||
|
@ -12,24 +12,14 @@
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from typing import Any, Optional
|
||||
from typing import Optional
|
||||
|
||||
import isctest.log
|
||||
from isctest.compat import dns_rcode
|
||||
|
||||
import dns.message
|
||||
|
||||
|
||||
# compatiblity with dnspython<2.0.0
|
||||
try:
|
||||
# In dnspython>=2.0.0, dns.rcode.Rcode class is available
|
||||
# pylint: disable=invalid-name
|
||||
dns_rcode = dns.rcode.Rcode # type: Any
|
||||
except AttributeError:
|
||||
# In dnspython<2.0.0, selected rcodes are available as integers directly
|
||||
# from dns.rcode
|
||||
dns_rcode = dns.rcode
|
||||
|
||||
|
||||
def cmd( # pylint: disable=too-many-arguments
|
||||
args,
|
||||
cwd=None,
|
||||
|
@ -16,21 +16,11 @@ import pytest
|
||||
|
||||
pytest.importorskip("dns", minversion="2.0.0")
|
||||
import isctest
|
||||
from isctest.compat import dns_rcode
|
||||
|
||||
import dns.message
|
||||
|
||||
|
||||
# compatiblity with dnspython<2.0.0
|
||||
try:
|
||||
# In dnspython>=2.0.0, dns.rcode.Rcode class is available
|
||||
# pylint: disable=invalid-name
|
||||
dns_rcode = dns.rcode.Rcode # type: Any
|
||||
except AttributeError:
|
||||
# In dnspython<2.0.0, selected rcodes are available as integers directly
|
||||
# from dns.rcode
|
||||
dns_rcode = dns.rcode
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"qname,source,rcode",
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user