diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3d6ef46b..d8790842 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,11 +53,11 @@ jobs: ;; esac - name: Install - run: pip install -e . + run: pip install . - name: Run tests run: pytest -v - name: Tile slide - run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/small.svs + run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs windows: name: Windows needs: pre-commit @@ -117,7 +117,7 @@ jobs: python examples/deepzoom/deepzoom_tile.py -h >/dev/null - name: Tile slide # Reads OPENSLIDE_PATH - run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/small.svs + run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs - name: Archive wheel uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index 78dc7415..87d0e176 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ /dist /MANIFEST /*.egg-info -/openslide/_convert*.so *.pyc diff --git a/MANIFEST.in b/MANIFEST.in index f0efabdd..c0b2779b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include *.md +include *.md pytest.ini recursive-include doc *.py *.rst recursive-include examples *.html *.js *.png *.py recursive-include tests *.png *.py *.svs *.tiff diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..218e0493 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +minversion = 6.0 +# don't try to import openslide from the source directory, since it doesn't +# have the compiled extension module +addopts = --import-mode importlib +# allow tests to import common module +pythonpath = tests diff --git a/tests/__init__.py b/tests/common.py similarity index 97% rename from tests/__init__.py rename to tests/common.py index b65dafdf..1ca8fc25 100644 --- a/tests/__init__.py +++ b/tests/common.py @@ -45,7 +45,7 @@ def file_path(name): - return Path(__file__).parent / name + return Path(__file__).parent / 'fixtures' / name def maybe_supported(f): diff --git a/tests/boxes.png b/tests/fixtures/boxes.png similarity index 100% rename from tests/boxes.png rename to tests/fixtures/boxes.png diff --git a/tests/boxes.tiff b/tests/fixtures/boxes.tiff similarity index 100% rename from tests/boxes.tiff rename to tests/fixtures/boxes.tiff diff --git a/tests/small.svs b/tests/fixtures/small.svs similarity index 100% rename from tests/small.svs rename to tests/fixtures/small.svs diff --git a/tests/unopenable.tiff b/tests/fixtures/unopenable.tiff similarity index 100% rename from tests/unopenable.tiff rename to tests/fixtures/unopenable.tiff diff --git a/tests/unreadable.svs b/tests/fixtures/unreadable.svs similarity index 100% rename from tests/unreadable.svs rename to tests/fixtures/unreadable.svs diff --git a/tests/test_base.py b/tests/test_base.py index dc961625..1ffc186f 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -19,9 +19,9 @@ import unittest -from openslide import ImageSlide, OpenSlide, open_slide +from common import file_path -from . import file_path +from openslide import ImageSlide, OpenSlide, open_slide class TestLibrary(unittest.TestCase): diff --git a/tests/test_deepzoom.py b/tests/test_deepzoom.py index 332cf0a4..892d9d04 100644 --- a/tests/test_deepzoom.py +++ b/tests/test_deepzoom.py @@ -19,11 +19,11 @@ import unittest +from common import file_path + from openslide import ImageSlide, OpenSlide from openslide.deepzoom import DeepZoomGenerator -from . import file_path - class _BoxesDeepZoomTest: def setUp(self): diff --git a/tests/test_imageslide.py b/tests/test_imageslide.py index 64540dc5..d3a22977 100644 --- a/tests/test_imageslide.py +++ b/tests/test_imageslide.py @@ -20,11 +20,10 @@ import unittest from PIL import Image +from common import file_path, maybe_supported from openslide import ImageSlide, OpenSlideCache, OpenSlideError -from . import file_path, maybe_supported - class TestImageWithoutOpening(unittest.TestCase): def test_detect_format(self): diff --git a/tests/test_openslide.py b/tests/test_openslide.py index 62de390a..52bffdd2 100644 --- a/tests/test_openslide.py +++ b/tests/test_openslide.py @@ -23,6 +23,7 @@ import unittest from PIL import Image +from common import file_path, maybe_supported from openslide import ( OpenSlide, @@ -31,8 +32,6 @@ OpenSlideUnsupportedFormatError, ) -from . import file_path, maybe_supported - class TestCache(unittest.TestCase): @maybe_supported