Unit testing - Extract function let's you hit hard to hit conditions
def f():
if rare_condition:
raise TypeError("Don't do that") # missed in coverage
becomes
def g(r): # new unit test targets this with g(True)
if r:
raise TypeError()
def f():
g(r) # now covered!
Post
December 5, 2019