You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I am probably doing something wrong, but I have been battling with this for a while... So far, when using the MolSSI cookiecutter I always moved the tests folder outside the Python package folder just after creating the repository and I never encountered any problems. However, in a recent project I decided to keep the MolSSI cookiecutter structure (tests folder inside the Python package folder) and while at first things seemed to work well, I encountered a problem when I started defining custom command line arguments in conftest.py.
The problem is the following. When I defined a custom command line option in conftest.py using pytest_addoption (to be used in a fixture with "session" scope by passing pytestconfig as argument of the fixture, also defined in the same conftest.py file), the pytest command started failing because the custom option could not be found.
If I run pytest <PACKAGE>/tests, everything works as expected, but running pytest fails. This happens despite having the following pytest.ini file:
Everything seems to work as expected if I either move the conftest.py file in the root directory (which I don't think is clean) or if I move the tests directory outside of the Python package and change the pytest.ini file as follows:
[pytest]
minversion = 6.0
testpaths =
tests/
(as I used to do for other projects).
Am I doing something wrong or the way the cookiecutter is set up does not fully work with a conftest.py file in <PACKAGE>/tests/?
The text was updated successfully, but these errors were encountered:
RMeli
changed the title
Test folder outside of Python package?
Test folder outside Python package?
Nov 11, 2021
RMeli
changed the title
Test folder outside Python package?
Tests folder outside Python package?
Nov 11, 2021
Hello. I am probably doing something wrong, but I have been battling with this for a while... So far, when using the MolSSI cookiecutter I always moved the
tests
folder outside the Python package folder just after creating the repository and I never encountered any problems. However, in a recent project I decided to keep the MolSSI cookiecutter structure (tests
folder inside the Python package folder) and while at first things seemed to work well, I encountered a problem when I started defining custom command line arguments inconftest.py
.The problem is the following. When I defined a custom command line option in
conftest.py
usingpytest_addoption
(to be used in a fixture with"session"
scope by passingpytestconfig
as argument of the fixture, also defined in the sameconftest.py
file), thepytest
command started failing because the custom option could not be found.If I run
pytest <PACKAGE>/tests
, everything works as expected, but runningpytest
fails. This happens despite having the followingpytest.ini
file:Everything seems to work as expected if I either move the
conftest.py
file in the root directory (which I don't think is clean) or if I move thetests
directory outside of the Python package and change thepytest.ini
file as follows:(as I used to do for other projects).
Am I doing something wrong or the way the cookiecutter is set up does not fully work with a
conftest.py
file in<PACKAGE>/tests/
?The text was updated successfully, but these errors were encountered: