@@ -198,7 +198,7 @@ class StrTests(unittest.TestCase):
198
198
def test_cont_text (self ):
199
199
self .assertEqual (
200
200
str (Frame (OP_CONT , b" cr\xc3 \xa8 me" , fin = False )),
201
- "CONT crème [text, 7 bytes, continued]" ,
201
+ "CONT ' crème' [text, 7 bytes, continued]" ,
202
202
)
203
203
204
204
def test_cont_binary (self ):
@@ -210,7 +210,7 @@ def test_cont_binary(self):
210
210
def test_cont_final_text (self ):
211
211
self .assertEqual (
212
212
str (Frame (OP_CONT , b" cr\xc3 \xa8 me" )),
213
- "CONT crème [text, 7 bytes]" ,
213
+ "CONT ' crème' [text, 7 bytes]" ,
214
214
)
215
215
216
216
def test_cont_final_binary (self ):
@@ -222,8 +222,8 @@ def test_cont_final_binary(self):
222
222
def test_cont_text_truncated (self ):
223
223
self .assertEqual (
224
224
str (Frame (OP_CONT , b"caf\xc3 \xa9 " * 16 , fin = False )),
225
- "CONT café café café café café café café café café caf ..."
226
- "afé café café café café [text, 96 bytes, continued]" ,
225
+ "CONT ' café café café café café café café café café ca ..."
226
+ "fé café café café café ' [text, 96 bytes, continued]" ,
227
227
)
228
228
229
229
def test_cont_binary_truncated (self ):
@@ -236,20 +236,26 @@ def test_cont_binary_truncated(self):
236
236
def test_text (self ):
237
237
self .assertEqual (
238
238
str (Frame (OP_TEXT , b"caf\xc3 \xa9 " )),
239
- "TEXT café [5 bytes]" ,
239
+ "TEXT ' café' [5 bytes]" ,
240
240
)
241
241
242
242
def test_text_non_final (self ):
243
243
self .assertEqual (
244
244
str (Frame (OP_TEXT , b"caf\xc3 \xa9 " , fin = False )),
245
- "TEXT café [5 bytes, continued]" ,
245
+ "TEXT ' café' [5 bytes, continued]" ,
246
246
)
247
247
248
248
def test_text_truncated (self ):
249
249
self .assertEqual (
250
250
str (Frame (OP_TEXT , b"caf\xc3 \xa9 " * 16 )),
251
- "TEXT café café café café café café café café café caf..."
252
- "afé café café café café [96 bytes]" ,
251
+ "TEXT 'café café café café café café café café café ca..."
252
+ "fé café café café café ' [96 bytes]" ,
253
+ )
254
+
255
+ def test_text_with_newline (self ):
256
+ self .assertEqual (
257
+ str (Frame (OP_TEXT , b"Hello\n world!" )),
258
+ "TEXT 'Hello\\ nworld!' [12 bytes]" ,
253
259
)
254
260
255
261
def test_binary (self ):
@@ -286,13 +292,19 @@ def test_close_reason(self):
286
292
def test_ping (self ):
287
293
self .assertEqual (
288
294
str (Frame (OP_PING , b"" )),
289
- "PING [0 bytes]" ,
295
+ "PING '' [0 bytes]" ,
290
296
)
291
297
292
298
def test_ping_text (self ):
293
299
self .assertEqual (
294
300
str (Frame (OP_PING , b"ping" )),
295
- "PING ping [text, 4 bytes]" ,
301
+ "PING 'ping' [text, 4 bytes]" ,
302
+ )
303
+
304
+ def test_ping_text_with_newline (self ):
305
+ self .assertEqual (
306
+ str (Frame (OP_PING , b"ping\n " )),
307
+ "PING 'ping\\ n' [text, 5 bytes]" ,
296
308
)
297
309
298
310
def test_ping_binary (self ):
@@ -304,13 +316,19 @@ def test_ping_binary(self):
304
316
def test_pong (self ):
305
317
self .assertEqual (
306
318
str (Frame (OP_PONG , b"" )),
307
- "PONG [0 bytes]" ,
319
+ "PONG '' [0 bytes]" ,
308
320
)
309
321
310
322
def test_pong_text (self ):
311
323
self .assertEqual (
312
324
str (Frame (OP_PONG , b"pong" )),
313
- "PONG pong [text, 4 bytes]" ,
325
+ "PONG 'pong' [text, 4 bytes]" ,
326
+ )
327
+
328
+ def test_pong_text_with_newline (self ):
329
+ self .assertEqual (
330
+ str (Frame (OP_PONG , b"pong\n " )),
331
+ "PONG 'pong\\ n' [text, 5 bytes]" ,
314
332
)
315
333
316
334
def test_pong_binary (self ):
0 commit comments