Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Testing Covering Your Bases HTML Reports

Joanna Dudley
Joanna Dudley
4,727 Points

HTML coverage report without Workspaces?

How do I get a HTML coverage report when using an IDE or a text editor with my local terminal?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

If you have coverage installed on your local machine, you should be able to generate an html file locally using coverage html. You can then open the file using a browser.

To install coverage

See note at end of previous using coverage video Teacher's Notes:

Installing coverage.py

pip install coverage

Using coverage.py

Make sure you test file can be run from the command line without the -m unittest argument.

coverage run tests.py

Generate a report

coverage report or coverage report -m if you want the missed lines.

coverage.py documentation

To open a file in Chrome, try one of the following:

  • Drag the file into Google Chrome from your computer's desktop or folder. Your cursor displays a little + sign if the action is successful.
  • Type the location, also known as the path, of the file in the address bar, then press Enter.
  • Try these keyboard shortcuts: Ctrl+O (Windows and Linux); ⌘+O (Mac)

That's an excellent answer, and it completely works for me, thanks Chris! Just one follow-up Q: when I run this in my terminal...

python -m http.server

... how do I quit it? It appears the usual CTRL+D isn't responding