Skip to content

Commit

Permalink
Add test for full event propagation
Browse files Browse the repository at this point in the history
This test verifies that a JSON document that is followed by some further
content still generates all parsing events, and only after that it
fails. This mimics the original issue reported in #123.

Signed-off-by: Rodrigo Tobar <[email protected]>
  • Loading branch information
rtobar committed Oct 25, 2024
1 parent 0d6a290 commit f079276
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def test_lazy(backend):
basic_parse = backend.basic_parse_gen(io.BytesIO(INVALID_JSONS[0]))
assert basic_parse is not None

def test_extra_content_still_generates_results(backend):
"""Extra content raises an error, but still generates all events"""
with pytest.raises(common.JSONError):
events = []
for event in backend.basic_parse(JSON + b"#"):
events.append(event)
assert events == JSON_EVENTS

def test_boundary_lexeme(backend):
buf_size = JSON.index(b'false') + 1
events = list(backend.basic_parse(JSON, buf_size=buf_size))
Expand Down

0 comments on commit f079276

Please sign in to comment.