Skip to content

Commit

Permalink
Merge pull request #208 from bgilbert/pytest
Browse files Browse the repository at this point in the history
Fix running pytest in root of repo
  • Loading branch information
bgilbert authored Jul 12, 2023
2 parents fe362fb + 7d2b9dd commit 8878e59
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
/dist
/MANIFEST
/*.egg-info
/openslide/_convert*.so
*.pyc
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/__init__.py → tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


def file_path(name):
return Path(__file__).parent / name
return Path(__file__).parent / 'fixtures' / name


def maybe_supported(f):
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_deepzoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_imageslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_openslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import unittest

from PIL import Image
from common import file_path, maybe_supported

from openslide import (
OpenSlide,
Expand All @@ -31,8 +32,6 @@
OpenSlideUnsupportedFormatError,
)

from . import file_path, maybe_supported


class TestCache(unittest.TestCase):
@maybe_supported
Expand Down

0 comments on commit 8878e59

Please sign in to comment.