Skip to content

Commit

Permalink
tests: change session scoped fixture to be function scoped (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Jul 15, 2024
1 parent d5cfe2c commit a8d8a0c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/func/test_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@pytest.fixture(scope="module")
def fake_dataset(tmpdir_factory):
def fake_dir(tmpdir_factory):
# Create fake images in labeled dirs
data_path = Path(tmpdir_factory.mktemp("data"))
for i, (img, label) in enumerate(FakeData()):
Expand All @@ -20,10 +20,13 @@ def fake_dataset(tmpdir_factory):
img.save(data_path / label / f"{i}.jpg")

# Create dataset from images
uri = data_path.as_uri()
return data_path.as_uri()


@pytest.fixture
def fake_dataset(fake_dir):
return (
DataChain.from_storage(uri, type="image")
DataChain.from_storage(fake_dir, type="image")
.map(text=lambda file: file.parent.split("/")[-1], output=str)
.map(label=lambda text: int(text), output=int)
.save("fake")
Expand Down

0 comments on commit a8d8a0c

Please sign in to comment.