Disable tests that require external network access.

Disable tests using external network access by setting
`_network_available = False`, as RHEL 9 build environment does
not allow external connections.

Resolves: RHBZ#1914296
This commit is contained in:
Rafael Guterres Jeffman 2021-04-22 11:16:15 -03:00
parent 133812c04a
commit 6f5ff8ca0a
2 changed files with 110 additions and 1 deletions

View File

@ -0,0 +1,105 @@
From 0414551fab97825fb826882b9c23c1a3ea0b71ea Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Thu, 22 Apr 2021 10:08:41 -0300
Subject: [PATCH] Skip tests that require external network connection.
---
tests/test_async.py | 11 ++---------
tests/test_query.py | 9 ++-------
tests/test_resolver.py | 10 ++--------
tests/test_resolver_override.py | 9 ++-------
4 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/tests/test_async.py b/tests/test_async.py
index 0252f22..370c6bb 100644
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -38,15 +38,8 @@ try:
except Exception:
_ssl_available = False
-
-# Some tests require the internet to be available to run, so let's
-# skip those if it's not there.
-_network_available = True
-try:
- socket.gethostbyname('dnspython.org')
-except socket.gaierror:
- _network_available = False
-
+# RHEL 9 build environment does not have provide external network access.
+_network_available = False
# Probe for IPv4 and IPv6
query_addresses = []
diff --git a/tests/test_query.py b/tests/test_query.py
index 2cff377..99dc873 100644
--- a/tests/test_query.py
+++ b/tests/test_query.py
@@ -36,13 +36,8 @@ import dns.query
import dns.tsigkeyring
import dns.zone
-# Some tests require the internet to be available to run, so let's
-# skip those if it's not there.
-_network_available = True
-try:
- socket.gethostbyname('dnspython.org')
-except socket.gaierror:
- _network_available = False
+# RHEL 9 build environment does not have provide external network access.
+_network_available = False
# Some tests use a "nano nameserver" for testing. It requires trio
# and threading, so try to import it and if it doesn't work, skip
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
index 4f5643d..b26ab65 100644
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -18,7 +18,6 @@
from io import StringIO
import selectors
import sys
-import socket
import time
import unittest
@@ -31,13 +30,8 @@ import dns.resolver
import dns.tsig
import dns.tsigkeyring
-# Some tests require the internet to be available to run, so let's
-# skip those if it's not there.
-_network_available = True
-try:
- socket.gethostbyname('dnspython.org')
-except socket.gaierror:
- _network_available = False
+# RHEL 9 build environment does not have provide external network access.
+_network_available = False
# Some tests use a "nano nameserver" for testing. It requires trio
# and threading, so try to import it and if it doesn't work, skip
diff --git a/tests/test_resolver_override.py b/tests/test_resolver_override.py
index ac93316..036a42e 100644
--- a/tests/test_resolver_override.py
+++ b/tests/test_resolver_override.py
@@ -9,13 +9,8 @@ import dns.rdataclass
import dns.rdatatype
import dns.resolver
-# Some tests require the internet to be available to run, so let's
-# skip those if it's not there.
-_network_available = True
-try:
- socket.gethostbyname('dnspython.org')
-except socket.gaierror:
- _network_available = False
+# RHEL 9 build environment does not have provide external network access.
+_network_available = False
@unittest.skipIf(not _network_available, "Internet not reachable")
--
2.30.2

View File

@ -14,7 +14,7 @@
Name: python-%{py_package_name} Name: python-%{py_package_name}
Version: 2.1.0 Version: 2.1.0
Release: 4%{?dist} Release: 5%{?dist}
Summary: DNS toolkit for Python Summary: DNS toolkit for Python
# The entire package is licensed with both licenses, see LICENSE file # The entire package is licensed with both licenses, see LICENSE file
@ -22,6 +22,7 @@ License: ISC and MIT
URL: http://www.dnspython.org URL: http://www.dnspython.org
Source0: https://github.com/rthalley/%{pypi_name}/archive/v%{version}%{rctag}/%{pypi_name}-%{version}%{rctag}.tar.gz Source0: https://github.com/rthalley/%{pypi_name}/archive/v%{version}%{rctag}/%{pypi_name}-%{version}%{rctag}.tar.gz
Patch0: 0001-Skip-tests-that-require-external-network-connection_rhbz#1914296.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python3-devel BuildRequires: python3-devel
@ -110,6 +111,9 @@ pytest -k "not testCanonicalNameDangling"
} }
%changelog %changelog
* Thu Apr 22 2021 Rafael Jeffman <rjeffman@redhat.com> - 2.1.0-5
- Skip tests that require external network connection.
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.1.0-4 * Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.1.0-4
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937