Repository navigation
Closed as not planned
Labels
WontfixInvalid, out-of-scope, or other inappropriate issues
Description
Situation
Test fail with errors collecting on 2 files inside docs.
To Reproduce
Steps to reproduce the behavior:
PYTHONPATH=/sw/build.build/semver-py310-3.0.1-1/semver-3.0.1/tests:/sw/build.build/semver-py310-3.0.1-1/semver-3.0.1/build/lib /sw/bin/pytest-3.10
================================================================= test session starts ==================================================================
platform darwin -- Python 3.10.4, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /sw/build.build/semver-py310-3.0.1-1/semver-3.0.1, configfile: setup.cfg, testpaths: tests, docs
plugins: hypothesis-6.36.0, cov-2.6.1
collected 348 items / 2 errors / 346 selected
======================================================================== ERRORS ========================================================================
_______________________________________________________ ERROR collecting docs/advanced/coerce.py _______________________________________________________
/sw/lib/python3.8/site-packages/_pytest/runner.py:311: in from_call
result: Optional[TResult] = func()
/sw/lib/python3.8/site-packages/_pytest/runner.py:341: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/sw/lib/python3.8/site-packages/_pytest/doctest.py:532: in collect
module = import_path(self.fspath)
/sw/lib/python3.8/site-packages/_pytest/pathlib.py:544: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('coerce', '/sw/build.build/semver-py38-3.0.1-1/semver-3.0.1/tests/coerce.py', PosixPath('/sw/build.build/semver-py38-3.0.1-1/semver-3.0.1/docs/advanced/coerce.py'))
_________________________________________________ ERROR collecting docs/advanced/semverwithvprefix.py __________________________________________________
/sw/lib/python3.8/site-packages/_pytest/runner.py:311: in from_call
result: Optional[TResult] = func()
/sw/lib/python3.8/site-packages/_pytest/runner.py:341: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/sw/lib/python3.8/site-packages/_pytest/doctest.py:532: in collect
module = import_path(self.fspath)
/sw/lib/python3.8/site-packages/_pytest/pathlib.py:544: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('semverwithvprefix', '/sw/build.build/semver-py38-3.0.1-1/semver-3.0.1/tests/semverwithvprefix.py', PosixPath('/sw/build.build/semver-py38-3.0.1-1/semver-3.0.1/docs/advanced/semverwithvprefix.py'))
=============================================================== short test summary info ================================================================
ERROR docs/advanced/coerce.py - _pytest.pathlib.ImportPathMismatchError: ('coerce', '/sw/build.build/semver-py310-3.0.1-1/semver-3.0.1/tests/coerce.p...
ERROR docs/advanced/semverwithvprefix.py - _pytest.pathlib.ImportPathMismatchError: ('semverwithvprefix', '/sw/build.build/semver-py310-3.0.1-1/semve...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Expected Behavior
Tests pass
Environment
- OS: macOS 10.14.6
- Python version 3.8 and 3.10 tested
- Version of semver library : 3.0.1
Additional context
semver-2.13.0 built and passed tests on same system.
Metadata
Metadata
Assignees
Labels
WontfixInvalid, out-of-scope, or other inappropriate issues
Type
Fields
SIze
None yet
Activity
GHA: Use matrix to test MacOS too
tomschr commentedon Jun 30, 2023
Hi @nieder,
thank you for your report, much appreciated!
This is a bit hard to dissect so I've added MacOS to our GitHub Action. The GHA job succeeds!
I've added now MacOS for every tested Python version.
I don't know what's wrong with your environment, but I cannot reproduce it. It may be even not related to semver.
Could you investigate a bit further?
GHA: Use matrix to test MacOS too
GHA: Use matrix to test MacOS too
nieder commentedon Jul 2, 2023
Figured it out kind of.
If I call
pytestdirectly from the source root directory, the tests fail looking for a module fromtests:If I add $builddir/tests to PYTHONPATH, it looks to be grabbing an older installed version of semver:
So I add
$builddir/build/libto PYTHONPATH as well, and get the error above:That the error was complaining about a mismatch between identically named file in
testsanddocsmade me play with how pytest was being called. If I cd intotests, then call the same command as in the last attempt, the tests all pass. Don't know why it's behaving like this, however.tomschr commentedon Jul 3, 2023
Thanks for the detailed analysis, @nieder! 👍
The steps you did look wrong to me. These are usually not necessary. Are you using pytest from your system or from the virtual Python environment? This can make a difference.
Normally you use Tox. That does all the things for you. If you don't have Tox installed on your MacOS, do the following preparation steps:
Start with a virtual Python environment like:
Activate the virtual Python environment:
Install all dependencies:
This is similar to other Python projects. The GitHub Actions uses the above steps too. This is the recommended way. Anything else would lead to strange errors that other things are taken into account.
Depending on what Python versions you have installed, you can use
toxin different ways. This is described here:https://python-semver.readthedocs.io/en/latest/contribute/run-test-suite.html
I'm inclined to close this issue as it seems this is something on your system rather than with the project itself.
tomschr commentedon Jul 3, 2023
This is how a successful Tox run looks like:
Successful Tox run (click me)
Successful Tox run with verbosity option enabled (click me)
tomschr commentedon Jul 5, 2023
I think I close it for the time being. If you have anything else, feel free to comment or reopen it.
Thank you!