diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-01-10 14:34:05 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@python.org> | 2020-01-10 14:34:05 (GMT) |
commit | c39b52f1527868c7ada9385669c38edf98858921 (patch) | |
tree | dff7a3c55d0d8c5f01bcb20bc66fac69aa2cd6dd /Lib/test/test_poplib.py | |
parent | 4c53e63cc966f98e141a09bc435b9f9c713b152d (diff) | |
download | cpython-c39b52f1527868c7ada9385669c38edf98858921.zip cpython-c39b52f1527868c7ada9385669c38edf98858921.tar.gz cpython-c39b52f1527868c7ada9385669c38edf98858921.tar.bz2 |
bpo-39259: poplib now rejects timeout = 0 (GH-17912)
poplib.POP3 and poplib.POP3_SSL now raise a ValueError
if the given timeout for their constructor is zero to
prevent the creation of a non-blocking socket.
Diffstat (limited to 'Lib/test/test_poplib.py')
-rw-r--r-- | Lib/test/test_poplib.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index 911cba1..7f06d19 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -481,7 +481,7 @@ class TestTimeouts(TestCase): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(60) # Safety net. Look issue 11812 self.port = test_support.bind_port(self.sock) - self.thread = threading.Thread(target=self.server, args=(self.evt,self.sock)) + self.thread = threading.Thread(target=self.server, args=(self.evt, self.sock)) self.thread.daemon = True self.thread.start() self.evt.wait() @@ -505,12 +505,12 @@ class TestTimeouts(TestCase): def testTimeoutDefault(self): self.assertIsNone(socket.getdefaulttimeout()) - socket.setdefaulttimeout(30) + socket.setdefaulttimeout(test_support.LOOPBACK_TIMEOUT) try: pop = poplib.POP3(HOST, self.port) finally: socket.setdefaulttimeout(None) - self.assertEqual(pop.sock.gettimeout(), 30) + self.assertEqual(pop.sock.gettimeout(), test_support.LOOPBACK_TIMEOUT) pop.close() def testTimeoutNone(self): @@ -524,9 +524,11 @@ class TestTimeouts(TestCase): pop.close() def testTimeoutValue(self): - pop = poplib.POP3(HOST, self.port, timeout=30) - self.assertEqual(pop.sock.gettimeout(), 30) + pop = poplib.POP3(HOST, self.port, timeout=test_support.LOOPBACK_TIMEOUT) + self.assertEqual(pop.sock.gettimeout(), test_support.LOOPBACK_TIMEOUT) pop.close() + with self.assertRaises(ValueError): + poplib.POP3(HOST, self.port, timeout=0) def test_main(): |