mirror of https://github.com/python/cpython.git
Issue #7449, part 8: don't skip the whole test_asynchat if threading is missing
TestFifo can be executed without the threading module
This commit is contained in:
parent
be595d336c
commit
09227b9111
|
@ -1,17 +1,19 @@
|
||||||
# test asynchat
|
# test asynchat
|
||||||
|
|
||||||
import asyncore, asynchat, socket, threading, time
|
import asyncore, asynchat, socket, time
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
try:
|
||||||
# Skip tests if thread module does not exist.
|
import threading
|
||||||
test_support.import_module('thread')
|
except ImportError:
|
||||||
|
threading = None
|
||||||
|
|
||||||
HOST = test_support.HOST
|
HOST = test_support.HOST
|
||||||
SERVER_QUIT = 'QUIT\n'
|
SERVER_QUIT = 'QUIT\n'
|
||||||
|
|
||||||
class echo_server(threading.Thread):
|
if threading:
|
||||||
|
class echo_server(threading.Thread):
|
||||||
# parameter to determine the number of bytes passed back to the
|
# parameter to determine the number of bytes passed back to the
|
||||||
# client each send
|
# client each send
|
||||||
chunk_size = 1
|
chunk_size = 1
|
||||||
|
@ -57,7 +59,7 @@ def run(self):
|
||||||
conn.close()
|
conn.close()
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
|
|
||||||
class echo_client(asynchat.async_chat):
|
class echo_client(asynchat.async_chat):
|
||||||
|
|
||||||
def __init__(self, terminator, server_port):
|
def __init__(self, terminator, server_port):
|
||||||
asynchat.async_chat.__init__(self)
|
asynchat.async_chat.__init__(self)
|
||||||
|
@ -84,7 +86,7 @@ def found_terminator(self):
|
||||||
self.buffer = ""
|
self.buffer = ""
|
||||||
|
|
||||||
|
|
||||||
def start_echo_server():
|
def start_echo_server():
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
s = echo_server(event)
|
s = echo_server(event)
|
||||||
s.start()
|
s.start()
|
||||||
|
@ -94,6 +96,7 @@ def start_echo_server():
|
||||||
return s, event
|
return s, event
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class TestAsynchat(unittest.TestCase):
|
class TestAsynchat(unittest.TestCase):
|
||||||
usepoll = False
|
usepoll = False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue