Skip to content

Tests folder outside Python package? #144

@RMeli

Description

@RMeli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions