Py.Test: reporting and HTML output

This is not a technical issue. However, I cannot find my .HTML report, which should be generated using:

py.test --cov-report html pytest / 01_smoke.py

I thought he would put it in the parent location or in the test script. Not both I and I could not find. So I think that it is not generated at all?

+4
source share
2 answers

I think you also need to specify the directory / file that you want to span, like py.test --cov=MYPKG --cov-report=html , after which html/index.html is generated.

+10
source

if you do not specify --cov = / path / to / code, then it will not generate html at all.

 $ py.test --cov-report html test_smoke.py == test session starts == platform linux2 -- Python 2.7.12, pytest-3.4.0, py-1.5.2, pluggy-0.6.0 rootdir: /home/someuser/somedir, inifile: plugins: xdist-1.22.0, forked-0.2, cov-2.5.1 collected 3 items test_smoke.py ... [100%] == 3 passed in 0.67 seconds == 

We see that there is no message that the result was created ... However, if we specify --cov = ...

 $ py.test --cov-report html test_smoke.py --cov=/path/to/code == test session starts == platform linux2 -- Python 2.7.12, pytest-3.4.0, py-1.5.2, pluggy-0.6.0 rootdir: /home/someuser/somedir, inifile: plugins: xdist-1.22.0, forked-0.2, cov-2.5.1 collected 3 items test_smoke.py ... [100%] ---------- coverage: platform linux2, python 2.7.12-final-0 ---------- Coverage HTML written to dir htmlcov 

Now we see that there are no statistics for past tests, instead we see that the coverage was written in HTML and sent to the default directory: ./ htmlcov

NOTE: if you want to use a different directory, then bind: / path / directory / to the html output type β†’ py.test --cov-report html: / path / to / htmldir test_smoke.py --cov = / path / to /code

If you see a simple html file, this indicates that your problem is --cov = / path / to / my / pkg, maybe ... sure that the code you are testing lives here

+1
source

Source: https://habr.com/ru/post/1490575/


All Articles