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

Excluding code from coverage.py "to skip certain lines"

Was anyone curious how to skip certain lines of code from coverage.py, as Kenneth mentions at 1min 30sec. If so, I was curious, I looked into it, and I thought I'd share an example:

Coverage.py will look for **comments* marking clauses for exclusion. In this code, the β€œif debug” clause is excluded from reporting:*

a = my_function1()
if debug:   # pragma: no cover
    msg = "blah blah"
    log_message(msg, a)
b = my_function2()

One more example from same site:

def only_one_choice(x):
    if x:
        blah1()
        blah2()
    else:       # pragma: no cover
        # x is always true.
        blah3()

I'm particularly interested in this practical topic as I'm viewing job descriptions that ask for Experience testing at API/services level Hope that might help someone!