Skip to content

Commit

Permalink
Textbook file closing for test files
Browse files Browse the repository at this point in the history
  • Loading branch information
ml31415 committed May 27, 2024
1 parent 9d4dfad commit 138df2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/integration/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

def test_performance(benchmark):
path = RESOURCES_DIR / "data/27312315.bz2"
data = bz2.open(path).read()
with bz2.open(path) as f:
data = f.read()
result = benchmark.pedantic(stream_decode_lines, args=(data,))
assert len(result) == 50854
for msg in result:
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ def test_responses(path):
def test_archive(path):
mc = MarketSubscriptionCache()
i = 0
for i, line in enumerate(bz2.open(path), start=1):
msg = stream_decode(line)
assert isinstance(msg, MCM)
mc.update(msg)
with bz2.open(path) as f:
for i, line in enumerate(f, start=1):
msg = stream_decode(line)
assert isinstance(msg, MCM)
mc.update(msg)

required_count = LINE_COUNT.get(path.name)
if required_count:
Expand Down

0 comments on commit 138df2d

Please sign in to comment.