99import shutil
1010import sys
1111import time
12+ import websockify # type: ignore
1213from subprocess import Popen
1314from typing import List
1415
2526
2627npm_checked = False
2728
28- EMTEST_SKIP_PYTHON_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_PYTHON_DEV_PACKAGES' , '0' ))
2929EMTEST_SKIP_NODE_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_NODE_DEV_PACKAGES' , '0' ))
3030
3131
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-
4432def clean_processes (processes ):
4533 for p in processes :
4634 if getattr (p , 'exitcode' , None ) is None and getattr (p , 'returncode' , None ) is None :
@@ -77,11 +65,6 @@ def __enter__(self):
7765 process = Popen ([os .path .abspath ('server' )])
7866 self .processes .append (process )
7967
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-
8568 # start the websocket proxy
8669 print ('running websockify on %d, forward to tcp %d' % (self .listen_port , self .target_port ), file = sys .stderr )
8770 # source_is_ipv6=True here signals to websockify that it should prefer ipv6 address when
@@ -202,8 +185,6 @@ def setUpClass(cls):
202185 def test_sockets_echo (self , harness_class , port , args ):
203186 if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
204187 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' )
207188 if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
208189 self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
209190
@@ -230,8 +211,6 @@ def test_sdl2_sockets_echo(self):
230211 def test_sockets_async_echo (self , harness_class , port , args ):
231212 if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
232213 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' )
235214 if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
236215 self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
237216
@@ -252,8 +231,6 @@ def test_sockets_async_bad_port(self):
252231 def test_sockets_echo_bigdata (self , harness_class , port , args ):
253232 if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
254233 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' )
257234 if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
258235 self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
259236 sockets_include = '-I' + test_file ('sockets' )
@@ -271,7 +248,6 @@ def test_sockets_echo_bigdata(self, harness_class, port, args):
271248 self .btest_exit ('test_sockets_echo_bigdata.c' , cflags = [sockets_include , '-DSOCKK=%d' % harness .listen_port ] + args )
272249
273250 @no_windows ('This test is Unix-specific.' )
274- @requires_python_dev_packages
275251 @requires_dev_dependency ('ws' )
276252 def test_sockets_partial (self ):
277253 for harness in [
@@ -282,7 +258,6 @@ def test_sockets_partial(self):
282258 self .btest_exit ('sockets/test_sockets_partial_client.c' , assert_returncode = 165 , cflags = ['-DSOCKK=%d' % harness .listen_port ])
283259
284260 @no_windows ('This test is Unix-specific.' )
285- @requires_python_dev_packages
286261 @requires_dev_dependency ('ws' )
287262 def test_sockets_select_server_down (self ):
288263 for harness in [
@@ -293,7 +268,6 @@ def test_sockets_select_server_down(self):
293268 self .btest_exit ('sockets/test_sockets_select_server_down_client.c' , cflags = ['-DSOCKK=%d' % harness .listen_port ])
294269
295270 @no_windows ('This test is Unix-specific.' )
296- @requires_python_dev_packages
297271 @requires_dev_dependency ('ws' )
298272 def test_sockets_select_server_closes_connection_rw (self ):
299273 for harness in [
@@ -326,8 +300,6 @@ def test_enet(self):
326300 def test_nodejs_sockets_echo (self , harness_class , port , args ):
327301 if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
328302 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' )
331303 if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
332304 self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
333305
@@ -340,7 +312,6 @@ def test_nodejs_sockets_connect_failure(self):
340312 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 )
341313
342314 @requires_native_clang
343- @requires_python_dev_packages
344315 def test_nodejs_sockets_echo_subprotocol (self ):
345316 # Test against a Websockified server with compile time configured WebSocket subprotocol. We use a Websockified
346317 # 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):
353324 self .assertContained (['connect: ws://127.0.0.1:59168, base64,binary' , 'connect: ws://127.0.0.1:59168/, base64,binary' ], out )
354325
355326 @requires_native_clang
356- @requires_python_dev_packages
357327 def test_nodejs_sockets_echo_subprotocol_runtime (self ):
358328 # Test against a Websockified server with runtime WebSocket configuration. We specify both url and subprotocol.
359329 # In this test we have *deliberately* used the wrong port '-DSOCKK=12345' to configure the echo_client.c, so
0 commit comments