-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-DNStests.patch
More file actions
116 lines (99 loc) · 4.53 KB
/
Copy pathpython-DNStests.patch
File metadata and controls
116 lines (99 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From 9a583b9665c50dfe27b0965128649ae1a7cd2ac6 Mon Sep 17 00:00:00 2001
From: Kacper Kornet <draenog@pld-linux.org>
Date: Mon, 20 May 2013 01:08:50 +0100
Subject: [PATCH] Mark tests that require access to resolver
---
Lib/test/checkDNS.py | 3 +++
Lib/test/test_mimetools.py | 2 ++
Lib/test/test_smtplib.py | 7 +++++++
Lib/test/test_urllib.py | 2 ++
4 files changed, 14 insertions(+)
create mode 100644 Lib/test/checkDNS.py
new file mode 100644
index 0000000..f77cbe7
diff -urNp -x '*.orig' Python-2.7.18.org/Lib/test/checkDNS.py Python-2.7.18/Lib/test/checkDNS.py
--- Python-2.7.18.org/Lib/test/checkDNS.py 1970-01-01 01:00:00.000000000 +0100
+++ Python-2.7.18/Lib/test/checkDNS.py 2021-09-26 12:34:35.277872284 +0200
@@ -0,0 +1,3 @@
+import os
+
+canresolve = os.access("/etc/resolv.conf", os.R_OK)
diff -urNp -x '*.orig' Python-2.7.18.org/Lib/test/test_mimetools.py Python-2.7.18/Lib/test/test_mimetools.py
--- Python-2.7.18.org/Lib/test/test_mimetools.py 2020-04-19 23:13:39.000000000 +0200
+++ Python-2.7.18/Lib/test/test_mimetools.py 2021-09-26 12:34:35.277872284 +0200
@@ -1,5 +1,6 @@
import unittest
from test import test_support
+from test import checkDNS
import string
import StringIO
@@ -27,6 +28,7 @@ class MimeToolsTest(unittest.TestCase):
mimetools.decode(i, o, enc)
self.assertEqual(o.getvalue(), start)
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def test_boundary(self):
s = set([""])
for i in xrange(100):
diff -urNp -x '*.orig' Python-2.7.18.org/Lib/test/test_smtplib.py Python-2.7.18/Lib/test/test_smtplib.py
--- Python-2.7.18.org/Lib/test/test_smtplib.py 2020-04-19 23:13:39.000000000 +0200
+++ Python-2.7.18/Lib/test/test_smtplib.py 2021-09-26 12:34:35.281205654 +0200
@@ -10,6 +10,7 @@ import select
import unittest
from test import test_support
+from test import checkDNS
try:
import threading
@@ -60,11 +61,13 @@ class GeneralTests(unittest.TestCase):
self.thread.join()
test_support.threading_cleanup(*self._threads)
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testBasic1(self):
# connects
smtp = smtplib.SMTP(HOST, self.port)
smtp.close()
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testBasic2(self):
# connects, include port in host name
smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
@@ -76,6 +79,7 @@ class GeneralTests(unittest.TestCase):
self.assertEqual(smtp.local_hostname, "testhost")
smtp.close()
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testTimeoutDefault(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
@@ -86,6 +90,7 @@ class GeneralTests(unittest.TestCase):
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testTimeoutNone(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
@@ -96,6 +101,7 @@ class GeneralTests(unittest.TestCase):
self.assertIsNone(smtp.sock.gettimeout())
smtp.close()
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testTimeoutValue(self):
smtp = smtplib.SMTP(HOST, self.port, timeout=30)
self.assertEqual(smtp.sock.gettimeout(), 30)
@@ -243,6 +249,7 @@ class DebuggingServerTests(unittest.Test
class NonConnectingTests(unittest.TestCase):
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def testNotConnected(self):
# Test various operations on an unconnected SMTP object that
# should raise exceptions (at present the attempt in SMTP.send
diff -urNp -x '*.orig' Python-2.7.18.org/Lib/test/test_urllib.py Python-2.7.18/Lib/test/test_urllib.py
--- Python-2.7.18.org/Lib/test/test_urllib.py 2020-04-19 23:13:39.000000000 +0200
+++ Python-2.7.18/Lib/test/test_urllib.py 2021-09-26 12:34:35.281205654 +0200
@@ -12,6 +12,7 @@ import tempfile
from test import test_support
from base64 import b64encode
+from test import checkDNS
def hexescape(char):
@@ -334,6 +335,7 @@ Connection: close
finally:
self.unfakehttp()
+ @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
def test_missing_localfile(self):
self.assertRaises(IOError, urllib.urlopen,
'file://localhost/a/missing/file.py')