Closed sheriferson closed 8 years ago
mean has tests in docstring written above it:
mean
""" >>> mean([1]) 1.0 >>> mean([1, 2]) 1.5 >>> mean([1, 2, 3]) 2.0 """ mean = lambda data: sum(data) / float(len(data))
but doctest does not detect them:
doctest
$ python simple_statistics.py -v ... 3 items had no tests: __main__ __main__.mean __main__.standard_deviation ...
This is because doctest only checks
The module docstring, and all function, class and method docstrings are searched.
https://docs.python.org/2/library/doctest.html#which-docstrings-are-examined
And the docstring that has the tests for mean is not the first line of the module.
I will either change mean to become a regularly defined function instead of being a lamda function, or move the tests for lambda functions to a separate text file.
mean
has tests in docstring written above it:but
doctest
does not detect them:This is because
doctest
only checkshttps://docs.python.org/2/library/doctest.html#which-docstrings-are-examined
And the docstring that has the tests for
mean
is not the first line of the module.I will either change
mean
to become a regularly defined function instead of being a lamda function, or move the tests for lambda functions to a separate text file.