2
2
3
3
from test import support
4
4
from test .support import socket_helper
5
+ from test .support import threading_helper
5
6
6
7
7
8
import asynchat
@@ -105,10 +106,10 @@ class TestAsynchat(unittest.TestCase):
105
106
usepoll = False
106
107
107
108
def setUp (self ):
108
- self ._threads = support .threading_setup ()
109
+ self ._threads = threading_helper .threading_setup ()
109
110
110
111
def tearDown (self ):
111
- support .threading_cleanup (* self ._threads )
112
+ threading_helper .threading_cleanup (* self ._threads )
112
113
113
114
def line_terminator_check (self , term , server_chunk ):
114
115
event = threading .Event ()
@@ -124,7 +125,7 @@ def line_terminator_check(self, term, server_chunk):
124
125
c .push (b"I'm not dead yet!" + term )
125
126
c .push (SERVER_QUIT )
126
127
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
127
- support .join_thread (s , timeout = TIMEOUT )
128
+ threading_helper .join_thread (s )
128
129
129
130
self .assertEqual (c .contents , [b"hello world" , b"I'm not dead yet!" ])
130
131
@@ -155,7 +156,7 @@ def numeric_terminator_check(self, termlen):
155
156
c .push (data )
156
157
c .push (SERVER_QUIT )
157
158
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
158
- support .join_thread (s , timeout = TIMEOUT )
159
+ threading_helper .join_thread (s )
159
160
160
161
self .assertEqual (c .contents , [data [:termlen ]])
161
162
@@ -175,7 +176,7 @@ def test_none_terminator(self):
175
176
c .push (data )
176
177
c .push (SERVER_QUIT )
177
178
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
178
- support .join_thread (s , timeout = TIMEOUT )
179
+ threading_helper .join_thread (s )
179
180
180
181
self .assertEqual (c .contents , [])
181
182
self .assertEqual (c .buffer , data )
@@ -187,7 +188,7 @@ def test_simple_producer(self):
187
188
p = asynchat .simple_producer (data + SERVER_QUIT , buffer_size = 8 )
188
189
c .push_with_producer (p )
189
190
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
190
- support .join_thread (s , timeout = TIMEOUT )
191
+ threading_helper .join_thread (s )
191
192
192
193
self .assertEqual (c .contents , [b"hello world" , b"I'm not dead yet!" ])
193
194
@@ -197,7 +198,7 @@ def test_string_producer(self):
197
198
data = b"hello world\n I'm not dead yet!\n "
198
199
c .push_with_producer (data + SERVER_QUIT )
199
200
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
200
- support .join_thread (s , timeout = TIMEOUT )
201
+ threading_helper .join_thread (s )
201
202
202
203
self .assertEqual (c .contents , [b"hello world" , b"I'm not dead yet!" ])
203
204
@@ -208,7 +209,7 @@ def test_empty_line(self):
208
209
c .push (b"hello world\n \n I'm not dead yet!\n " )
209
210
c .push (SERVER_QUIT )
210
211
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
211
- support .join_thread (s , timeout = TIMEOUT )
212
+ threading_helper .join_thread (s )
212
213
213
214
self .assertEqual (c .contents ,
214
215
[b"hello world" , b"" , b"I'm not dead yet!" ])
@@ -227,7 +228,7 @@ def test_close_when_done(self):
227
228
# where the server echoes all of its data before we can check that it
228
229
# got any down below.
229
230
s .start_resend_event .set ()
230
- support .join_thread (s , timeout = TIMEOUT )
231
+ threading_helper .join_thread (s )
231
232
232
233
self .assertEqual (c .contents , [])
233
234
# the server might have been able to send a byte or two back, but this
@@ -248,7 +249,7 @@ def test_push(self):
248
249
self .assertRaises (TypeError , c .push , 'unicode' )
249
250
c .push (SERVER_QUIT )
250
251
asyncore .loop (use_poll = self .usepoll , count = 300 , timeout = .01 )
251
- support .join_thread (s , timeout = TIMEOUT )
252
+ threading_helper .join_thread (s )
252
253
self .assertEqual (c .contents , [b'bytes' , b'bytes' , b'bytes' ])
253
254
254
255
0 commit comments