diff --git a/changelog.d/388.trivial.rst b/changelog.d/388.trivial.rst new file mode 100644 index 00000000..236bce6f --- /dev/null +++ b/changelog.d/388.trivial.rst @@ -0,0 +1,3 @@ +For pytest, switch to the more modern :mod:`importlib` approach +as it doesn't require to modify :data:`sys.path`: +https://docs.pytest.org/en/7.2.x/explanation/pythonpath.html \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 87ec3b8f..2673b0f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,12 +55,12 @@ semver = py.typed [tool:pytest] norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/ testpaths = tests docs -# pythonpath = src +pythonpath = src tests filterwarnings = ignore:Function 'semver.*:DeprecationWarning # ' <- This apostroph is just to fix syntax highlighting addopts = - # --import-mode=importlib + --import-mode=importlib --no-cov-on-fail --cov=semver --cov-report=term-missing diff --git a/tests/conftest.py b/tests/conftest.py index beecffc9..9017bbbe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,8 +4,6 @@ import semver -# sys.path.insert(0, "docs/usage") - from coerce import coerce # noqa:E402 from semverwithvprefix import SemVerWithVPrefix # noqa:E402 import packaging.version diff --git a/tox.ini b/tox.ini index 8ca917b8..2b47562e 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ python = [testenv] description = Run test suite for {basepython} allowlist_externals = make +skip_install = true commands = pytest {posargs:} deps = pytest