Browse Source

🎨 Auto format

pull/15515/head
pre-commit-ci-lite[bot] 1 month ago
committed by GitHub
parent
commit
29112d6d2b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      tests/test_sse.py

21
tests/test_sse.py

@ -332,10 +332,7 @@ def test_format_sse_event_preserves_trailing_newline():
def test_format_sse_event_preserves_trailing_double_newline():
assert (
format_sse_event(data_str="Hello\n\n")
== b"data: Hello\ndata: \ndata: \n\n"
)
assert format_sse_event(data_str="Hello\n\n") == b"data: Hello\ndata: \ndata: \n\n"
def test_format_sse_event_single_newline_data():
@ -346,33 +343,25 @@ def test_format_sse_event_crlf_normalizes_to_lf():
# \r\n is a valid SSE line terminator and should be normalized to \n
# for output, producing the same two data lines as \n input would.
assert (
format_sse_event(data_str="Hello\r\nWorld")
== b"data: Hello\ndata: World\n\n"
format_sse_event(data_str="Hello\r\nWorld") == b"data: Hello\ndata: World\n\n"
)
def test_format_sse_event_bare_cr_treated_as_line_break():
# Lone \r is also a valid SSE line terminator per the spec.
assert (
format_sse_event(data_str="Hello\rWorld")
== b"data: Hello\ndata: World\n\n"
)
assert format_sse_event(data_str="Hello\rWorld") == b"data: Hello\ndata: World\n\n"
def test_format_sse_event_unicode_line_separator_not_split():
# U+2028 LINE SEPARATOR is treated as a line break by str.splitlines()
# but is NOT a line terminator in the SSE spec. It must stay inside the
# data payload, not be promoted to a new "data:" line.
assert (
format_sse_event(data_str="A
B") == "data: A
B\n\n".encode()
)
assert format_sse_event(data_str="A
B") == "data: A
B\n\n".encode()
def test_format_sse_event_vertical_tab_not_split():
# \v is treated as a line break by splitlines() but not by SSE.
assert (
format_sse_event(data_str="A\vB") == b"data: A\x0bB\n\n"
)
assert format_sse_event(data_str="A\vB") == b"data: A\x0bB\n\n"
def test_format_sse_event_comment_preserves_trailing_newline():

Loading…
Cancel
Save