Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests folder outside Python package? #144

Open
RMeli opened this issue Nov 11, 2021 · 1 comment
Open

Tests folder outside Python package? #144

RMeli opened this issue Nov 11, 2021 · 1 comment

Comments

@RMeli
Copy link
Contributor

RMeli commented 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 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:

[pytest]
minversion = 6.0
testpaths =
    <PACKAGE>/tests/

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/?

@RMeli RMeli changed the title Test folder outside of Python package? Test folder outside Python package? Nov 11, 2021
@RMeli RMeli changed the title Test folder outside Python package? Tests folder outside Python package? Nov 11, 2021
@mikemhenry
Copy link
Contributor

Related to #140

I've ran into the same issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants