fix the network tests failed

This commit is contained in:
jinzhimin369 2020-11-10 21:21:59 +08:00
parent e447651077
commit fa0a5766bc
2 changed files with 42 additions and 3 deletions

View File

@ -14,7 +14,7 @@ messages, names, and records.
Name: python-dns
Summary: %{sum}
Version: 1.16.0
Release: 1
Release: 2
License: MIT
URL: http://www.dnspython.org/
Source0: http://www.dnspython.org/kits/%{version}/dnspython-%{version}.tar.gz
@ -23,6 +23,7 @@ BuildArch: noarch
Patch0: unicode_label_escapify.patch
Patch1: collections_abc.patch
Patch2: base64.patch
Patch3: retry-network-availble.patch
BuildRequires: python3-devel python3-setuptools python3-pycryptodome python3-ecdsa
@ -61,11 +62,14 @@ find examples -type f | xargs chmod a-x
%doc examples
%changelog
* Tue Nov 10 2020 jinzhimin<jinzhimin2@huawei.com> - 1.16.0-2
- fix the network tests failed
* Tue Nov 10 2020 jinzhimin<jinzhimin2@huawei.com> - 1.16.0-1
* update to 1.16.0
- update to 1.16.0
* Wed Oct 21 2020 jinzhimin<jinzhimin2@huawei.com> - 1.15.0-11
* remove python2-dns subpackage
- remove python2-dns subpackage
* Fri Dec 6 2019 caomeng<caomeng5@huawei.com> - 1.15.0-10
- Package init

View File

@ -0,0 +1,35 @@
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