@@ -1197,7 +1197,7 @@ def test_run_container_streaming(self):
1197
1197
sock = self .client .attach_socket (container , ws = False )
1198
1198
assert sock .fileno () > - 1
1199
1199
1200
- def test_run_container_reading_socket (self ):
1200
+ def test_run_container_reading_socket_http (self ):
1201
1201
line = 'hi there and stuff and things, words!'
1202
1202
# `echo` appends CRLF, `printf` doesn't
1203
1203
command = f"printf '{ line } '"
@@ -1217,6 +1217,25 @@ def test_run_container_reading_socket(self):
1217
1217
data = read_exactly (pty_stdout , next_size )
1218
1218
assert data .decode ('utf-8' ) == line
1219
1219
1220
+ @pytest .mark .xfail (condition = bool (os .environ .get ('DOCKER_CERT_PATH' , '' )),
1221
+ reason = 'DOCKER_CERT_PATH not respected for websockets' )
1222
+ def test_run_container_reading_socket_ws (self ):
1223
+ line = 'hi there and stuff and things, words!'
1224
+ # `echo` appends CRLF, `printf` doesn't
1225
+ command = f"printf '{ line } '"
1226
+ container = self .client .create_container (TEST_IMG , command ,
1227
+ detach = True , tty = False )
1228
+ self .tmp_containers .append (container )
1229
+
1230
+ opts = {"stdout" : 1 , "stream" : 1 , "logs" : 1 }
1231
+ pty_stdout = self .client .attach_socket (container , opts , ws = True )
1232
+ self .addCleanup (pty_stdout .close )
1233
+
1234
+ self .client .start (container )
1235
+
1236
+ data = pty_stdout .recv ()
1237
+ assert data .decode ('utf-8' ) == line
1238
+
1220
1239
@pytest .mark .timeout (10 )
1221
1240
def test_attach_no_stream (self ):
1222
1241
container = self .client .create_container (
0 commit comments