summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-03-28 04:41:34 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2008-03-28 04:41:34 (GMT)
commit023cd00ccc9bae7b26ad2dfd7b2d887c2f7b8e3d (patch)
tree29a2352c2ceb91ae630f2641d2d0bfae19c55a94
parent8b9091fba07b813b7486ef8fef279f2bf950570b (diff)
downloadcpython-023cd00ccc9bae7b26ad2dfd7b2d887c2f7b8e3d.zip
cpython-023cd00ccc9bae7b26ad2dfd7b2d887c2f7b8e3d.tar.gz
cpython-023cd00ccc9bae7b26ad2dfd7b2d887c2f7b8e3d.tar.bz2
Allow use of other ports so the test can pass if 9091 is in use
-rw-r--r--Lib/test/test_telnetlib.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 3a53ad9..8eee666 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -6,12 +6,14 @@ import time
from unittest import TestCase
from test import test_support
+PORT = 9091
def server(evt):
serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serv.settimeout(3)
serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- serv.bind(("", 9091))
+ global PORT
+ PORT = test_support.bind_port(serv, "", PORT)
serv.listen(5)
evt.set()
try:
@@ -36,24 +38,24 @@ class GeneralTests(TestCase):
def testBasic(self):
# connects
- telnet = telnetlib.Telnet("localhost", 9091)
+ telnet = telnetlib.Telnet("localhost", PORT)
telnet.sock.close()
def testTimeoutDefault(self):
# default
- telnet = telnetlib.Telnet("localhost", 9091)
+ telnet = telnetlib.Telnet("localhost", PORT)
self.assertTrue(telnet.sock.gettimeout() is None)
telnet.sock.close()
def testTimeoutValue(self):
# a value
- telnet = telnetlib.Telnet("localhost", 9091, timeout=30)
+ telnet = telnetlib.Telnet("localhost", PORT, timeout=30)
self.assertEqual(telnet.sock.gettimeout(), 30)
telnet.sock.close()
def testTimeoutDifferentOrder(self):
telnet = telnetlib.Telnet(timeout=30)
- telnet.open("localhost", 9091)
+ telnet.open("localhost", PORT)
self.assertEqual(telnet.sock.gettimeout(), 30)
telnet.sock.close()
@@ -62,7 +64,7 @@ class GeneralTests(TestCase):
previous = socket.getdefaulttimeout()
socket.setdefaulttimeout(30)
try:
- telnet = telnetlib.Telnet("localhost", 9091, timeout=None)
+ telnet = telnetlib.Telnet("localhost", PORT, timeout=None)
finally:
socket.setdefaulttimeout(previous)
self.assertEqual(telnet.sock.gettimeout(), 30)