Automating doctest?

35 views Asked by At

If I were to automate doctest.testmod() how would this occur? It appears testmod runs the tests over the module and provided a string result TestResults. Unsure how to parse this.

def average(values):
    """Computes the arithmetic mean of a list of numbers.
    >>> print(average([20, 30, 70])) 
    40.0
    """
    return sum(values) / len(values)

import doctest
r = doctest.testmod()
print(r)

# TestResults(failed=0, attempted=1)
0

There are 0 answers