Reduce conversion memory footprint
This commit is contained in:
@@ -74,3 +74,19 @@ def test_parse_log_file_rebuilds_record_after_embedded_newlines():
|
||||
assert records[0]["msg"] == "hellobroken-fragmentworld"
|
||||
assert records[0]["action"] == "Alert"
|
||||
assert records[1]["msg"] == "next"
|
||||
|
||||
|
||||
def test_parse_log_file_does_not_require_full_stream_read():
|
||||
class NoFullReadBytesIO(io.BytesIO):
|
||||
def read(self, size=-1):
|
||||
if size == -1:
|
||||
raise AssertionError("full stream read should not be used")
|
||||
return super().read(size)
|
||||
|
||||
stream = NoFullReadBytesIO(
|
||||
b'v015xxxxdate=2024-02-15 time=09:10:11 policy="Strict Policy" msg="blocked request"\n'
|
||||
)
|
||||
|
||||
records, _union_keys = parse_log_file(stream)
|
||||
|
||||
assert records[0]["policy"] == "Strict Policy"
|
||||
|
||||
Reference in New Issue
Block a user