diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 20:31:38 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 20:31:38 (GMT) |
commit | cf2f41919c226d1ac04ea74a0138eae3af030554 (patch) | |
tree | bfdbe947c13ff1b53b04b678df62a6b7a439385e /Lib | |
parent | fb35f65e8b3d59b9c8f7536a6359483c7f051fda (diff) | |
download | cpython-cf2f41919c226d1ac04ea74a0138eae3af030554.zip cpython-cf2f41919c226d1ac04ea74a0138eae3af030554.tar.gz cpython-cf2f41919c226d1ac04ea74a0138eae3af030554.tar.bz2 |
Hack: Fix some test_urllib2.net tests by getting them access to the
raw socket so they can check the timeout value. Should change the
code under test to expose the timeout in a more direct way.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_urllib2net.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 89ddaa4..17b5394 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -270,45 +270,47 @@ class OtherNetworkTests(unittest.TestCase): class TimeoutTest(unittest.TestCase): def test_http_basic(self): u = urllib2.urlopen("http://www.python.org") - self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + self.assertTrue(u.fp.raw.fp._sock.gettimeout() is None) def test_http_NoneWithdefault(self): prev = socket.getdefaulttimeout() socket.setdefaulttimeout(60) try: u = urllib2.urlopen("http://www.python.org", timeout=None) - self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) + self.assertTrue(u.fp.raw.fp._sock.gettimeout(), 60) finally: socket.setdefaulttimeout(prev) def test_http_Value(self): u = urllib2.urlopen("http://www.python.org", timeout=120) - self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) + self.assertEqual(u.fp.raw.fp._sock.gettimeout(), 120) def test_http_NoneNodefault(self): u = urllib2.urlopen("http://www.python.org", timeout=None) - self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) + self.assertTrue(u.fp.raw.fp._sock.gettimeout() is None) def test_ftp_basic(self): u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/") - self.assertTrue(u.fp.fp._sock.gettimeout() is None) + self.assertTrue(u.fp.fp.raw._sock.gettimeout() is None) def test_ftp_NoneWithdefault(self): prev = socket.getdefaulttimeout() socket.setdefaulttimeout(60) try: - u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) - self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", + timeout=None) + self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60) finally: socket.setdefaulttimeout(prev) def test_ftp_NoneNodefault(self): - u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=None) - self.assertTrue(u.fp.fp._sock.gettimeout() is None) + u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", + timeout=None) + self.assertTrue(u.fp.fp.raw._sock.gettimeout() is None) def test_ftp_Value(self): u = urllib2.urlopen("ftp://ftp.mirror.nl/pub/mirror/gnu/", timeout=60) - self.assertEqual(u.fp.fp._sock.gettimeout(), 60) + self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60) def test_main(): |