9
9
import shutil
10
10
import sys
11
11
import time
12
+ import websockify # type: ignore
12
13
from subprocess import Popen
13
14
from typing import List
14
15
25
26
26
27
npm_checked = False
27
28
28
- EMTEST_SKIP_PYTHON_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_PYTHON_DEV_PACKAGES' , '0' ))
29
29
EMTEST_SKIP_NODE_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_NODE_DEV_PACKAGES' , '0' ))
30
30
31
31
32
- def requires_python_dev_packages (func ):
33
- assert callable (func )
34
-
35
- @common .wraps (func )
36
- def decorated (self , * args , ** kwargs ):
37
- if EMTEST_SKIP_PYTHON_DEV_PACKAGES :
38
- return self .skipTest ('python websockify based tests are disabled by EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
39
- return func (self , * args , ** kwargs )
40
-
41
- return decorated
42
-
43
-
44
32
def clean_processes (processes ):
45
33
for p in processes :
46
34
if getattr (p , 'exitcode' , None ) is None and getattr (p , 'returncode' , None ) is None :
@@ -77,11 +65,6 @@ def __enter__(self):
77
65
process = Popen ([os .path .abspath ('server' )])
78
66
self .processes .append (process )
79
67
80
- try :
81
- import websockify # type: ignore
82
- except ModuleNotFoundError :
83
- raise Exception ('Unable to import module websockify. Run "python3 -m pip install websockify" or set environment variable EMTEST_SKIP_PYTHON_DEV_PACKAGES=1 to skip this test.' ) from None
84
-
85
68
# start the websocket proxy
86
69
print ('running websockify on %d, forward to tcp %d' % (self .listen_port , self .target_port ), file = sys .stderr )
87
70
# source_is_ipv6=True here signals to websockify that it should prefer ipv6 address when
@@ -202,8 +185,6 @@ def setUpClass(cls):
202
185
def test_sockets_echo (self , harness_class , port , args ):
203
186
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
204
187
self .skipTest ('requires native clang' )
205
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
206
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
207
188
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
208
189
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
209
190
@@ -230,8 +211,6 @@ def test_sdl2_sockets_echo(self):
230
211
def test_sockets_async_echo (self , harness_class , port , args ):
231
212
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
232
213
self .skipTest ('requires native clang' )
233
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
234
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
235
214
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
236
215
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
237
216
@@ -252,8 +231,6 @@ def test_sockets_async_bad_port(self):
252
231
def test_sockets_echo_bigdata (self , harness_class , port , args ):
253
232
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
254
233
self .skipTest ('requires native clang' )
255
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
256
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
257
234
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
258
235
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
259
236
sockets_include = '-I' + test_file ('sockets' )
@@ -271,7 +248,6 @@ def test_sockets_echo_bigdata(self, harness_class, port, args):
271
248
self .btest_exit ('test_sockets_echo_bigdata.c' , cflags = [sockets_include , '-DSOCKK=%d' % harness .listen_port ] + args )
272
249
273
250
@no_windows ('This test is Unix-specific.' )
274
- @requires_python_dev_packages
275
251
@requires_dev_dependency ('ws' )
276
252
def test_sockets_partial (self ):
277
253
for harness in [
@@ -282,7 +258,6 @@ def test_sockets_partial(self):
282
258
self .btest_exit ('sockets/test_sockets_partial_client.c' , assert_returncode = 165 , cflags = ['-DSOCKK=%d' % harness .listen_port ])
283
259
284
260
@no_windows ('This test is Unix-specific.' )
285
- @requires_python_dev_packages
286
261
@requires_dev_dependency ('ws' )
287
262
def test_sockets_select_server_down (self ):
288
263
for harness in [
@@ -293,7 +268,6 @@ def test_sockets_select_server_down(self):
293
268
self .btest_exit ('sockets/test_sockets_select_server_down_client.c' , cflags = ['-DSOCKK=%d' % harness .listen_port ])
294
269
295
270
@no_windows ('This test is Unix-specific.' )
296
- @requires_python_dev_packages
297
271
@requires_dev_dependency ('ws' )
298
272
def test_sockets_select_server_closes_connection_rw (self ):
299
273
for harness in [
@@ -326,8 +300,6 @@ def test_enet(self):
326
300
def test_nodejs_sockets_echo (self , harness_class , port , args ):
327
301
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
328
302
self .skipTest ('requires native clang' )
329
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
330
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
331
303
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
332
304
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
333
305
@@ -340,7 +312,6 @@ def test_nodejs_sockets_connect_failure(self):
340
312
self .do_runf ('sockets/test_sockets_echo_client.c' , r'connect failed: (Connection refused|Host is unreachable)' , regex = True , cflags = ['-DSOCKK=666' ], assert_returncode = NON_ZERO )
341
313
342
314
@requires_native_clang
343
- @requires_python_dev_packages
344
315
def test_nodejs_sockets_echo_subprotocol (self ):
345
316
# Test against a Websockified server with compile time configured WebSocket subprotocol. We use a Websockified
346
317
# server because as long as the subprotocol list contains binary it will configure itself to accept binary
@@ -353,7 +324,6 @@ def test_nodejs_sockets_echo_subprotocol(self):
353
324
self .assertContained (['connect: ws://127.0.0.1:59168, base64,binary' , 'connect: ws://127.0.0.1:59168/, base64,binary' ], out )
354
325
355
326
@requires_native_clang
356
- @requires_python_dev_packages
357
327
def test_nodejs_sockets_echo_subprotocol_runtime (self ):
358
328
# Test against a Websockified server with runtime WebSocket configuration. We specify both url and subprotocol.
359
329
# In this test we have *deliberately* used the wrong port '-DSOCKK=12345' to configure the echo_client.c, so
0 commit comments