Closed rienafairefr closed 6 years ago
it will always try to collect every test in the iotlabcli/ hierarchy
What do you mean by this ? It runs all tests or it displays coverage for all tests ?
I tried locally and there's indeed an issue when one wants to only run pytest on a single test. Example:
$ iotlabcli/tests/profile_test.py::TestM3Profile::test_valid_empty_profile
doesn't work: all tests are run. But this is not related to pytest-cov. I could fix it with the following pytest config (in setup.cfg):
[tool:pytest]
addopts = -v --ignore iotlabcli/integration
--cov=iotlabcli --cov-report=term --cov-report=xml --cov-report=html
--junit-xml=test-report.xml
--doctest-modules
--pep8
testpaths = iotlabcli
Using an empty PYTEST_ADDOPTS variable is not a good solution, since it will also clear other options (--doctest-module, --pep8, etc).
Also, having the global coverage when running a single test makes no sense and maybe the options related to coverage should be moved to the tests env in tox.ini. I tried that and it works well, will PR this, so you can try.
@rienafairefr, see #29
OK. Looks fixed by #29
Because of the setup.cfg (the --cov=iotlabcli part in addopts), when running pytest it will always try to collect every test in the iotlabcli/ hierarchy, even if we try to force it to run only a single test (e.g. by doing pytest iotlabcli/test/[...]) I could only force it to not collect everything by having an empty PYTEST_ADDOPTS environment variable. We could try to put the --cov parameters in a specific tox environement (tests-coverage) instead of the setup.cfg ?