Skip to content

Commit

Permalink
Revert "tests: try to restructure tests so that windows won't fail"
Browse files Browse the repository at this point in the history
This reverts commit 1951a56.
  • Loading branch information
ap-- committed Jul 30, 2020
1 parent 1951a56 commit e45ad36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
9 changes: 3 additions & 6 deletions paquo/tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
@pytest.fixture(scope='module')
def image_entry(svs_small):
with tempfile.TemporaryDirectory(prefix='paquo-') as tmpdir:
with QuPathProject(tmpdir) as qp:
entry = qp.add_image(svs_small)
qp.save()
yield entry
del entry
del qp
qp = QuPathProject(tmpdir)
entry = qp.add_image(svs_small)
yield entry


def test_image_entry_return_hierarchy(image_entry):
Expand Down
36 changes: 9 additions & 27 deletions paquo/tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@
# noinspection PyPackageRequirements
import pytest

from paquo.classes import QuPathPathClass
from paquo.images import ImageProvider
from paquo.projects import QuPathProject


@pytest.fixture(scope='function')
def new_project_with_tmpdir():
def new_project():
with tempfile.TemporaryDirectory(prefix='paquo-') as tmpdir:
qp = QuPathProject(tmpdir)
yield qp, tmpdir
del qp


@pytest.fixture(scope='function')
def new_project(new_project_with_tmpdir):
yield new_project_with_tmpdir[0]
yield QuPathProject(tmpdir)


def test_project_instance():
Expand All @@ -39,14 +31,11 @@ def test_project_create_no_dir():
q.save()


def test_project_open_with_filename():
with tempfile.TemporaryDirectory(prefix='paquo-') as tmpdir:
with QuPathProject(tmpdir, create=True) as qp:
qp.path_classes = [QuPathPathClass.create('abc')]
proj_fn = qp.path
del qp

QuPathProject(proj_fn, create=False)
def test_project_open_with_filename(new_project):
new_project.save()
# this points to path/project.qpproj
proj_fn = new_project.path
QuPathProject(proj_fn, create=False)


def test_project_uri(new_project):
Expand Down Expand Up @@ -105,9 +94,7 @@ def test_project_save_image_data(new_project, svs_small):
assert (entry.entry_path / "data.qpdata").is_file()


def test_project_image_uri_update(new_project_with_tmpdir, svs_small):

new_project, tmpdir = new_project_with_tmpdir
def test_project_image_uri_update(new_project, svs_small):

with tempfile.TemporaryDirectory(prefix="paquo-") as tmp:
new_svs_small = Path(tmp) / svs_small.name
Expand All @@ -118,22 +105,17 @@ def test_project_image_uri_update(new_project_with_tmpdir, svs_small):
# test that entry can be read
assert entry.is_readable()
assert all(new_project.is_readable().values())
del entry

entry = new_project.images[0]
# tempdir is cleanup up, entry is not readable anymore
assert not entry.is_readable()
assert not any(new_project.is_readable().values())
old_uri = entry.uri
del entry

# mapping for uris
uri2uri = {
old_uri: ImageProvider.uri_from_path(svs_small)
entry.uri: ImageProvider.uri_from_path(svs_small)
}
new_project.update_image_paths(uri2uri=uri2uri)

entry = new_project.images[0]
# test that entry can be read
assert entry.is_readable()
assert all(new_project.is_readable().values())

0 comments on commit e45ad36

Please sign in to comment.