Skip to content

Commit

Permalink
added fixture to clean session (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilongin authored Jul 12, 2024
1 parent b6cb0a4 commit 4190e08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def monkeypatch_session() -> Generator[MonkeyPatch, None, None]:
mpatch.undo()


@pytest.fixture(autouse=True)
def clean_session() -> None:
"""
Make sure we clean leftover session before each test case
"""
Session.cleanup_for_tests()


@pytest.fixture(scope="session", autouse=True)
def clean_environment(
monkeypatch_session: MonkeyPatch,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/lib/test_datachain_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def teardown(self):
self.value = MyMapper.TEARDOWN_VALUE


def test_udf(catalog):
def test_udf():
vals = ["a", "b", "c", "d", "e", "f"]
chain = DataChain.from_features(key=vals)

Expand All @@ -36,7 +36,7 @@ def test_udf(catalog):


@pytest.mark.skip(reason="Skip until tests module will be importer for unit-tests")
def test_udf_parallel(catalog):
def test_udf_parallel():
vals = ["a", "b", "c", "d", "e", "f"]
chain = DataChain.from_features(key=vals)

Expand All @@ -45,7 +45,7 @@ def test_udf_parallel(catalog):
assert res == [MyMapper.BOOTSTRAP_VALUE] * len(vals)


def test_no_bootstrap_for_callable(catalog):
def test_no_bootstrap_for_callable():
class MyMapper:
def __init__(self):
self._had_bootstrap = False
Expand Down

0 comments on commit 4190e08

Please sign in to comment.