#36 Investigate how to run py.test --cov with --functional
Closed: Fixed Opened by kparal.

As described in D23, we can't run py.test --cov libtaskotron --functional, it complains about an unknown option. Please investigate whether we can work around this somehow, or maybe send a simple patch to pytest-cov upstream, if possible. If we find out that we can't fix/work around this easily, that's also a valid outcome.


This ticket had assigned some Differential requests:
D23

@mkrizek found the problem, it fails to run when testing/ directory is not present, otherwise it runs.

I think that it's caused by pytest-cov package. When you run "py.test" without argument, it uses directory "testing/" by default. But when you specify "--cov", it is probably handled by "pytest-cov" package and it doesn't use "testing/" as default testing directory.

Now that I'm trying it, it's not problem with default directory as "testing/" and pytest-cov. "--functional" argument is added by testing/conftest.py and it is problem only when you specify both "--functional", "--cov" and don't specify "testing/" as a command line arguments.

OK, I understand it now. "--functional" argument is defined in "testing/conftest.py", so that argument is valid only for directory "testing/". When you run "py.test --functional" (without "testing/" directory specified), it only discovers tests in "testing/" directory and for them, "--functional" argument is defined. When you run "py.test --functional --cov libtaskotron testing/", you tell py.test to search for tests only in "testing/" directory so "--functional" argument is also defined. When you run "py.test --functional --cov libtaskotron", it is probably trying to run something from some other directory than "testing/", so "--functional" is not defined there.

To workaround this, you could move "testing/conftest.py" to project's root directory or always specify "testing/" directory as an argument for py.test.

To workaround this, you could move "testing/conftest.py" to project's root directory or always specify "testing/" directory as an argument for py.test.

I think the second one is better, otherwise some other files (with names matching the py.test patterns accidentally) might get run as well. Already implemented in D23.

Metadata