Issue #7857: test_logging: listener test now uses find_unused_port().
This commit is contained in:
parent
565d78586b
commit
3dd734fe03
|
@ -40,7 +40,8 @@ import string
|
|||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
from test.test_support import captured_stdout, run_with_locale, run_unittest
|
||||
from test.test_support import captured_stdout, run_with_locale, run_unittest,\
|
||||
find_unused_port
|
||||
import textwrap
|
||||
import threading
|
||||
import time
|
||||
|
@ -1573,12 +1574,12 @@ class ConfigDictTest(BaseTest):
|
|||
self.test_config1_ok(self.config11)
|
||||
|
||||
def setup_via_listener(self, text):
|
||||
PORT = 9030
|
||||
t = logging.config.listen(PORT)
|
||||
port = find_unused_port()
|
||||
t = logging.config.listen(port)
|
||||
t.start()
|
||||
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(('localhost', PORT))
|
||||
sock.connect(('localhost', port))
|
||||
|
||||
slen = struct.pack('>L', len(text))
|
||||
s = slen + text
|
||||
|
@ -1589,6 +1590,7 @@ class ConfigDictTest(BaseTest):
|
|||
sentsofar += sent
|
||||
left -= sent
|
||||
sock.close()
|
||||
finally:
|
||||
logging.config.stopListening()
|
||||
t.join()
|
||||
|
||||
|
|
Loading…
Reference in New Issue