Open kloczek opened 1 year ago
gentle ping 🤔
What are the contents of the directory where you're running the tests.
The tox target isolated
demonstrates how to run the tests outside of the source code directory.
I'm executing pytest in source root directory. Looks like tests/init.py is missing. After create empty tests/init.py pytest is able to pass units scanning however it fails in some units
- PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-spelling-8.0.0-2.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-spelling-8.0.0-2.fc36.x86_64/usr/lib/python3.9/site-packages
- /usr/bin/pytest -ra -m 'not network'
I'm not sure what you're doing there with the python path. It's possible you don't have enough entries for the interpreter to find everything. If you look at what the isolated
target in tox.ini does, you will see that it copies the test files out of the tests directory into a temporary directory and then runs pytest there, rather than from the root of the source tree.
I'm not sure what you're doing there with the python path. It's possible you don't have enough entries for the interpreter to find everything.
That is only entry added on top of default content of the sys.path
.
Executing test suite in in tox does not make to much sense in my case as package build is executed inside dedicated build env created only to build that package and in which are installed only build dependencies.
-m 'not network'
is standard part of my %pytest rpm macro (many python modules already standardised around that pytest mark to disable execution of the units which needs access to more than localhost). In this case it is not relevant,
If you look at what the
isolated
target in tox.ini does, you will see that it copies the test files out of the tests directory into a temporary directory and then runs pytest there, rather than from the root of the source tree.
None of the test suites should rely on such special procedures like copy something to special directory. Try to think that some build infras are building sometimes packages out of R/O directory structure. Please read about some examples of directories layouts provided in pytest documentation https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html
Did you try to reproduce this issue? 🤔
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)Here is pytest output:
Here is list of installed modules in build env