I installed plugin for pytest from here:http://pypi.python.org/pypi/pytest-cov. Then I have a simple test code:
pytest.py:
class TestNumbers:
def test_int_float(self):
assert 1 == 1.0
def test_int_str(self):
assert 1 == 1
I tried to test it with command: py.test --cov-report term --cov pytest.py
. But it doesn't work. Even if I gave the entire absolute path of pytest.py it was still no data for collecting. However if I use py.test pytest.py
, surely it tested Ok.
I am very confusing about this problem, thanks for help.
Try:
py.test --cov-report term --cov=. test.py
The --cov
parameter takes an argument saying which paths to cover. In your example, --cov
would consume test.py
, but then there were no arguments left for py.test about which files to test.
UPDATE: as @hpk42 points out, you need to call your example something other than pytest.py
. When I did this locally, I called it test.py
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With