summaryrefslogtreecommitdiff
path: root/Lib/test/test_telnetlib.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2015-11-28 12:24:52 -0500
committerR David Murray <rdmurray@bitdance.com>2015-11-28 12:24:52 -0500
commit4f09806e662928c5524ab5d792d73297c50494b3 (patch)
tree74a8b786e7c43de01493bc1b84ad1e38367219c4 /Lib/test/test_telnetlib.py
parent37f54219543f9cb6ebf6a94cfe1eb402bc9b5580 (diff)
downloadcpython-git-4f09806e662928c5524ab5d792d73297c50494b3.tar.gz
#25485: Add context manager support to Telnet class.
Patch by Stéphane Wirtel.
Diffstat (limited to 'Lib/test/test_telnetlib.py')
-rw-r--r--Lib/test/test_telnetlib.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 524bba37b3..23029e0c6f 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -42,6 +42,11 @@ class GeneralTests(TestCase):
telnet = telnetlib.Telnet(HOST, self.port)
telnet.sock.close()
+ def testContextManager(self):
+ with telnetlib.Telnet(HOST, self.port) as tn:
+ self.assertIsNotNone(tn.get_socket())
+ self.assertIsNone(tn.get_socket())
+
def testTimeoutDefault(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)