I have a pytest.ini file that has the following contents
[pytest]
testpaths = tests/database/* tests/*
addopts = -v --cov="merlot" --cov="merlot/sql" --cov-report term-missing
My tests are structured such that
tests | test1.py
| test2.py
|
| subfolder | test3.py
| test4.py
| test5.py
When I have testpaths = tests/* then no tests in subfolder are run, however the current invocation runs the tests in subfolder multiple times. The result looks like
tests/database/testDatabase.py::TestMerlotDB::testDbName PASSED [ 12%]
tests/database/testDatabase.py::TestMerlotDB::testResetIndex PASSED [ 25%]
tests/database/testDatabase.py::TestMerlotDB::testInsertRecord PASSED [ 37%]
tests/database/testDatabase.py::TestMerlotDB::testDbName PASSED [ 37%]
tests/database/testDatabase.py::TestMerlotDB::testResetIndex PASSED [ 37%]
tests/database/testDatabase.py::TestMerlotDB::testInsertRecord PASSED [ 37%]
tests/testMerlot.py::TestMerlotBrowser::testBrowser PASSED [ 50%]
tests/testMerlot.py::TestMerlotBrowser::test_go_to_URL PASSED [ 62%]
How can I fix my pytest.ini file so that the unit tests only run one time?
>Solution :
To fix your pytest.ini so that the unit tests only run once:
[pytest]
testpaths = tests
python_files = test*.py