fix tests failed

This commit is contained in:
jinzhimin369 2020-11-17 11:17:22 +08:00
parent 1259798d75
commit b605c484e5
3 changed files with 34 additions and 37 deletions

29
fix-failed-tests.patch Normal file
View File

@ -0,0 +1,29 @@
From e691f1219550ccda24276cbfffff5cf0d31d91d1 Mon Sep 17 00:00:00 2001
From: yangl777 <1525652683@qq.com>
Date: Tue, 17 Nov 2020 10:36:08 +0800
Subject: [PATCH] fix-failed-tests
---
tests/test_resolver.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
index 1738c1a..1e0c727 100644
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -31,11 +31,7 @@ from dns._compat import xrange, PY3
# 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
+_network_available = False
resolv_conf = u"""
/t/t
--
1.8.3.1

View File

@ -14,7 +14,7 @@ messages, names, and records.
Name: python-dns
Summary: %{sum}
Version: 1.16.0
Release: 2
Release: 3
License: MIT
URL: http://www.dnspython.org/
Source0: http://www.dnspython.org/kits/%{version}/dnspython-%{version}.tar.gz
@ -23,7 +23,7 @@ BuildArch: noarch
Patch0: unicode_label_escapify.patch
Patch1: collections_abc.patch
Patch2: base64.patch
Patch3: retry-network-availble.patch
Patch3: fix-failed-tests.patch
BuildRequires: python3-devel python3-setuptools python3-pycryptodome python3-ecdsa
@ -62,6 +62,9 @@ find examples -type f | xargs chmod a-x
%doc examples
%changelog
* Tue Nov 17 2020 jinzhimin<jinzhimin2@huawei.com> - 1.16.0-3
- fix tests failed
* Tue Nov 10 2020 jinzhimin<jinzhimin2@huawei.com> - 1.16.0-2
- fix the network tests failed

View File

@ -1,35 +0,0 @@
From 5e24db163fa5070bbb69f09473cf50436e5a323c Mon Sep 17 00:00:00 2001
From: jinzhimin <jinzhimin2@huawei.com>
Date: Tue, 10 Nov 2020 20:32:07 +0800
Subject: [PATCH] retry-network-availble
---
tests/test_resolver.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
index 1738c1a..b91ba0b 100644
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -32,10 +32,14 @@ from dns._compat import xrange, PY3
# 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
+count = 0
+while count < 5 and _network_available:
+ try:
+ socket.gethostbyname('dnspython.org')
+ _network_available = True
+ except socket.gaierror:
+ _network_available = False
+ count += 1
resolv_conf = u"""
/t/t
--
2.27.0