]> git.pld-linux.org Git - packages/python.git/blob - python-DNStests.patch
d652cb4cc9831ab76aeb7223d9ff68636c854cca
[packages/python.git] / python-DNStests.patch
1 From 9a583b9665c50dfe27b0965128649ae1a7cd2ac6 Mon Sep 17 00:00:00 2001
2 From: Kacper Kornet <draenog@pld-linux.org>
3 Date: Mon, 20 May 2013 01:08:50 +0100
4 Subject: [PATCH] Mark tests that require access to resolver
5
6 ---
7  Lib/test/checkDNS.py       | 3 +++
8  Lib/test/test_mimetools.py | 2 ++
9  Lib/test/test_smtplib.py   | 7 +++++++
10  Lib/test/test_urllib.py    | 2 ++
11  4 files changed, 14 insertions(+)
12  create mode 100644 Lib/test/checkDNS.py
13
14 diff --git a/Lib/test/checkDNS.py b/Lib/test/checkDNS.py
15 new file mode 100644
16 index 0000000..f77cbe7
17 --- /dev/null
18 +++ b/Lib/test/checkDNS.py
19 @@ -0,0 +1,3 @@
20 +import os
21 +
22 +canresolve = os.access("/etc/resolv.conf", os.R_OK)
23 diff --git a/Lib/test/test_mimetools.py b/Lib/test/test_mimetools.py
24 index 86a26dc..8f07ada 100644
25 --- a/Lib/test/test_mimetools.py
26 +++ b/Lib/test/test_mimetools.py
27 @@ -1,5 +1,6 @@
28  import unittest
29  from test import test_support
30 +from test import checkDNS
31  
32  import string
33  import StringIO
34 @@ -27,6 +28,7 @@ class MimeToolsTest(unittest.TestCase):
35              mimetools.decode(i, o, enc)
36              self.assertEqual(o.getvalue(), start)
37  
38 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
39      def test_boundary(self):
40          s = set([""])
41          for i in xrange(100):
42 diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
43 index 81806c9..d88fd97 100644
44 --- a/Lib/test/test_smtplib.py
45 +++ b/Lib/test/test_smtplib.py
46 @@ -10,6 +10,7 @@ import select
47  
48  import unittest
49  from test import test_support
50 +from test import checkDNS
51  
52  try:
53      import threading
54 @@ -60,11 +61,13 @@ class GeneralTests(unittest.TestCase):
55          self.thread.join()
56          test_support.threading_cleanup(*self._threads)
57  
58 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
59      def testBasic1(self):
60          # connects
61          smtp = smtplib.SMTP(HOST, self.port)
62          smtp.close()
63  
64 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
65      def testBasic2(self):
66          # connects, include port in host name
67          smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
68 @@ -76,6 +79,7 @@ class GeneralTests(unittest.TestCase):
69          self.assertEqual(smtp.local_hostname, "testhost")
70          smtp.close()
71  
72 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
73      def testTimeoutDefault(self):
74          self.assertTrue(socket.getdefaulttimeout() is None)
75          socket.setdefaulttimeout(30)
76 @@ -86,6 +90,7 @@ class GeneralTests(unittest.TestCase):
77          self.assertEqual(smtp.sock.gettimeout(), 30)
78          smtp.close()
79  
80 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
81      def testTimeoutNone(self):
82          self.assertTrue(socket.getdefaulttimeout() is None)
83          socket.setdefaulttimeout(30)
84 @@ -96,6 +101,7 @@ class GeneralTests(unittest.TestCase):
85          self.assertTrue(smtp.sock.gettimeout() is None)
86          smtp.close()
87  
88 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
89      def testTimeoutValue(self):
90          smtp = smtplib.SMTP(HOST, self.port, timeout=30)
91          self.assertEqual(smtp.sock.gettimeout(), 30)
92 @@ -243,6 +249,7 @@ class DebuggingServerTests(unittest.TestCase):
93  
94  class NonConnectingTests(unittest.TestCase):
95  
96 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
97      def testNotConnected(self):
98          # Test various operations on an unconnected SMTP object that
99          # should raise exceptions (at present the attempt in SMTP.send
100 diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
101 index 3a273f8..e6a4c73 100644
102 --- a/Lib/test/test_urllib.py
103 +++ b/Lib/test/test_urllib.py
104 @@ -11,6 +11,7 @@ import StringIO
105  
106  from test import test_support
107  from base64 import b64encode
108 +from test import checkDNS
109  
110  
111  def hexescape(char):
112 @@ -222,6 +223,7 @@ Content-Type: text/html; charset=iso-8859-1
113          finally:
114              self.unfakehttp()
115  
116 +    @unittest.skipUnless(checkDNS.canresolve, 'test requires name resolution')
117      def test_missing_localfile(self):
118          self.assertRaises(IOError, urllib.urlopen,
119                  'file://localhost/a/missing/file.py')
120 -- 
121 1.8.3.rc2
122
This page took 0.025129 seconds and 2 git commands to generate.