Skip to content

Commit

Permalink
fix changed behavior in tmp path on osx
Browse files Browse the repository at this point in the history
on osx tmp_path fixture resolves the symlink from /var to /private/var, while
`tempfile.mkstemp` does not - relative path check would fail.
  • Loading branch information
k-dominik committed Apr 27, 2023
1 parent 34f6695 commit ba9a190
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/test_ilastik/test_workflows/test_DatasetInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@


@pytest.fixture
def png_stack_dir(tmp_path) -> Path:
def stack_path(tmp_path) -> Path:
p = tmp_path / "stacksubpath"
p.mkdir()
return p


@pytest.fixture
def png_stack_dir(stack_path) -> Path:
for i in range(3):
pil_image = PilImage.fromarray((numpy.random.rand(520, 697, 3) * 255).astype(numpy.uint8))
with open(tmp_path / f"c_cells_{i}.png", "wb") as png_file:
with open(stack_path / f"c_cells_{i}.png", "wb") as png_file:
pil_image.save(png_file, "png")
return tmp_path
return stack_path


@pytest.fixture
Expand All @@ -32,13 +39,13 @@ def h5_1_100_200_1_1(tmp_path):


@pytest.fixture
def h5_stack_dir(tmp_path):
def h5_stack_dir(stack_path):
for i in range(3):
raw = (numpy.random.rand(1, 100, 200, 1, 1) * 255).astype(numpy.uint8)
with h5py.File(tmp_path / f"2d_apoptotic_binary_{i}.h5", "w") as f:
with h5py.File(stack_path / f"2d_apoptotic_binary_{i}.h5", "w") as f:
f.create_group("volume")
f["volume/data"] = raw
return tmp_path
return stack_path


def dir_to_colon_glob(dir_path: str):
Expand Down Expand Up @@ -82,8 +89,8 @@ def h5_star_stack(h5_stack_dir) -> str:


@pytest.fixture
def empty_project_file() -> h5py.File:
return h5py.File(tempfile.mkstemp()[1], "r+")
def empty_project_file(tmp_path) -> h5py.File:
return h5py.File(tmp_path / "empty_project_file.ilp", "a")


def test_create_nickname(h5_colon_path_stack):
Expand Down

0 comments on commit ba9a190

Please sign in to comment.