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

pytest-cov collection #28

Closed
rienafairefr opened this issue May 29, 2018 · 3 comments · Fixed by #29
Closed

pytest-cov collection #28

rienafairefr opened this issue May 29, 2018 · 3 comments · Fixed by #29

Comments

@rienafairefr
Copy link
Contributor

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 ?

@aabadie aabadie changed the title pyest-cov collection pytest-cov collection May 30, 2018
@aabadie
Copy link
Contributor

aabadie commented May 30, 2018

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.

@aabadie
Copy link
Contributor

aabadie commented May 30, 2018

@rienafairefr, see #29

@rienafairefr
Copy link
Contributor Author

OK. Looks fixed by #29

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

Successfully merging a pull request may close this issue.

2 participants