diff options
author | Facundo Batista <facundobatista@gmail.com> | 2008-05-29 16:39:26 +0000 |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2008-05-29 16:39:26 +0000 |
commit | 4f1b1ed975fe25170d00559e63f992c9bf8e9b8a (patch) | |
tree | 0f2a0434dc9ad0181633f649611e417aa4a6ea61 /Lib/test/test_poplib.py | |
parent | f18a70720542268586e271bbadab3fb0332b8a39 (diff) | |
download | cpython-git-4f1b1ed975fe25170d00559e63f992c9bf8e9b8a.tar.gz |
Fixed the semantic of timeout for socket.create_connection and
all the upper level libraries that use it, including urllib2.
Added and fixed some tests, and changed docs correspondingly.
Thanks to John J Lee for the patch and the pusing, :)
Diffstat (limited to 'Lib/test/test_poplib.py')
-rw-r--r-- | Lib/test/test_poplib.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index 54b87866d4..18ed224f7a 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -40,28 +40,29 @@ class GeneralTests(TestCase): pop.sock.close() def testTimeoutDefault(self): - # default - pop = poplib.POP3(HOST, self.port) - self.assertTrue(pop.sock.gettimeout() is None) - pop.sock.close() - - def testTimeoutValue(self): - # a value - pop = poplib.POP3(HOST, self.port, timeout=30) + self.assertTrue(socket.getdefaulttimeout() is None) + socket.setdefaulttimeout(30) + try: + pop = poplib.POP3("localhost", self.port) + finally: + socket.setdefaulttimeout(None) self.assertEqual(pop.sock.gettimeout(), 30) pop.sock.close() def testTimeoutNone(self): - # None, having other default - previous = socket.getdefaulttimeout() + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: pop = poplib.POP3(HOST, self.port, timeout=None) finally: - socket.setdefaulttimeout(previous) - self.assertEqual(pop.sock.gettimeout(), 30) + socket.setdefaulttimeout(None) + self.assertTrue(pop.sock.gettimeout() is None) pop.sock.close() + def testTimeoutValue(self): + pop = poplib.POP3("localhost", self.port, timeout=30) + self.assertEqual(pop.sock.gettimeout(), 30) + pop.sock.close() def test_main(verbose=None): |