添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
愉快的猴子  ·  C++ 17 constexpr 與 ...·  1 月前    · 
时尚的豌豆  ·  Laravel pipeline ...·  1 月前    · 
慈祥的数据线  ·  JSON 数据类型 | ...·  6 天前    · 
坐怀不乱的跑步机  ·  SQLite Insert empty ...·  4 天前    · 
另类的扁豆  ·  CoreWebView2.CapturePr ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

This is not a technical question at all really. However, I can not locate my .HTML report that is supposed to be generated using:

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

I thought for sure it would place it in the parent location, or the test script location. Does neither and I have not been able to locate. So I am thinking it is not being generated at all?

Yes, I had. I'll post here to show it gives no more info than I have already. --cov-report=type type of report to generate: term, term-missing, annotate, html, xml (multi-allowed) Dave Jul 9, 2013 at 21:31 Thanks, hpk42. That did work. The output .html is basically a printout of the script, but. It's a step forward. Dave Jul 11, 2013 at 18:41

if you do not specify --cov=/path/to/code then it will not generate the 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 can see that there is no message that output 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

We now see that there are no stats for tests that passed, instead we see that coverage was written to HTML and sent to the default directory: ./htmlcov

NOTE: if you want a different directory, then affix :/path/to/directory to the output style html -> py.test --cov-report html:/path/to/htmldir test_smoke.py --cov=/path/to/code

If you see a plain html file, this is an indication that your problem is the --cov=/path/to/my/pkg perhaps... are you sure that the code you are testing lives here?

If you want to generate report in html, give full file path of the test file.

py.test --cov-report html test_file_name.py --cov=/home/ubuntu/venv/python3/lib/python3.7/site-packages/test/

Then start a python server

python -m http.server 

Navigate to the html file in htmlcov directory

http://0.0.0.0:8000/venv/python3/lib/python3.7/site-packages/htmlcov/

You will see the report

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.