Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctest does not run docstring tests for mean and other lambda functions #2

Closed
sheriferson opened this issue Feb 4, 2016 · 0 comments

Comments

@sheriferson
Copy link
Owner

mean has tests in docstring written above it:

"""
>>> 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:

$ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant