mirror of
https://github.com/python/cpython.git
synced 2025-09-09 02:11:51 +00:00
bpo-40275: Adding threading_helper submodule in test.support (GH-20263)
This commit is contained in:
parent
7d80b35af1
commit
e80697d687
46 changed files with 483 additions and 428 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
from test import support
|
||||
from test.support import socket_helper
|
||||
from test.support import threading_helper
|
||||
|
||||
import asynchat
|
||||
import asyncore
|
||||
|
@ -103,10 +104,10 @@ class TestAsynchat(unittest.TestCase):
|
|||
usepoll = False
|
||||
|
||||
def setUp(self):
|
||||
self._threads = support.threading_setup()
|
||||
self._threads = threading_helper.threading_setup()
|
||||
|
||||
def tearDown(self):
|
||||
support.threading_cleanup(*self._threads)
|
||||
threading_helper.threading_cleanup(*self._threads)
|
||||
|
||||
def line_terminator_check(self, term, server_chunk):
|
||||
event = threading.Event()
|
||||
|
@ -122,7 +123,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
c.push(b"I'm not dead yet!" + term)
|
||||
c.push(SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
|
||||
|
||||
|
@ -153,7 +154,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
c.push(data)
|
||||
c.push(SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [data[:termlen]])
|
||||
|
||||
|
@ -173,7 +174,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
c.push(data)
|
||||
c.push(SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [])
|
||||
self.assertEqual(c.buffer, data)
|
||||
|
@ -185,7 +186,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8)
|
||||
c.push_with_producer(p)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
|
||||
|
||||
|
@ -195,7 +196,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
data = b"hello world\nI'm not dead yet!\n"
|
||||
c.push_with_producer(data+SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
|
||||
|
||||
|
@ -206,7 +207,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
c.push(b"hello world\n\nI'm not dead yet!\n")
|
||||
c.push(SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents,
|
||||
[b"hello world", b"", b"I'm not dead yet!"])
|
||||
|
@ -225,7 +226,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
# where the server echoes all of its data before we can check that it
|
||||
# got any down below.
|
||||
s.start_resend_event.set()
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
|
||||
self.assertEqual(c.contents, [])
|
||||
# the server might have been able to send a byte or two back, but this
|
||||
|
@ -246,7 +247,7 @@ class TestAsynchat(unittest.TestCase):
|
|||
self.assertRaises(TypeError, c.push, 'unicode')
|
||||
c.push(SERVER_QUIT)
|
||||
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
|
||||
support.join_thread(s)
|
||||
threading_helper.join_thread(s)
|
||||
self.assertEqual(c.contents, [b'bytes', b'bytes', b'bytes'])
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue