diff --git a/tests/unit/sync/test_status.py b/tests/unit/sync/test_status.py index c5e9dda..1e602ad 100644 --- a/tests/unit/sync/test_status.py +++ b/tests/unit/sync/test_status.py @@ -1,5 +1,7 @@ from __future__ import annotations +import contextlib + import hypothesis.strategies as st from hypothesis import assume from hypothesis import given @@ -24,15 +26,13 @@ def test_legacy_status(status_dict): hrefs_a = {meta_a["href"] for meta_a, meta_b in status_dict.values()} hrefs_b = {meta_b["href"] for meta_a, meta_b in status_dict.values()} assume(len(hrefs_a) == len(status_dict) == len(hrefs_b)) - status = SqliteStatus() - status.load_legacy_status(status_dict) - assert dict(status.to_legacy_status()) == status_dict + with contextlib.closing(SqliteStatus()) as status: + status.load_legacy_status(status_dict) + assert dict(status.to_legacy_status()) == status_dict - for ident, (meta_a, meta_b) in status_dict.items(): - ident_a, meta2_a = status.get_by_href_a(meta_a["href"]) - ident_b, meta2_b = status.get_by_href_b(meta_b["href"]) - assert meta2_a.to_status() == meta_a - assert meta2_b.to_status() == meta_b - assert ident_a == ident_b == ident - - status.close() + for ident, (meta_a, meta_b) in status_dict.items(): + ident_a, meta2_a = status.get_by_href_a(meta_a["href"]) + ident_b, meta2_b = status.get_by_href_b(meta_b["href"]) + assert meta2_a.to_status() == meta_a + assert meta2_b.to_status() == meta_b + assert ident_a == ident_b == ident