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