{"action":"opened","issue":{"url":"https://api.github.com/repos/sheriferson/simple-statistics-py/issues/2","repository_url":"https://api.github.com/repos/sheriferson/simple-statistics-py","labels_url":"https://api.github.com/repos/sheriferson/simple-statistics-py/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/sheriferson/simple-statistics-py/issues/2/comments","events_url":"https://api.github.com/repos/sheriferson/simple-statistics-py/issues/2/events","html_url":"https://github.com/sheriferson/simple-statistics-py/issues/2","id":131220993,"number":2,"title":"`doctest` does not run docstring tests for mean and other lambda functions","user":{"login":"sheriferson","id":3160968,"avatar_url":"https://avatars.githubusercontent.com/u/3160968?v=3","gravatar_id":"","url":"https://api.github.com/users/sheriferson","html_url":"https://github.com/sheriferson","followers_url":"https://api.github.com/users/sheriferson/followers","following_url":"https://api.github.com/users/sheriferson/following{/other_user}","gists_url":"https://api.github.com/users/sheriferson/gists{/gist_id}","starred_url":"https://api.github.com/users/sheriferson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sheriferson/subscriptions","organizations_url":"https://api.github.com/users/sheriferson/orgs","repos_url":"https://api.github.com/users/sheriferson/repos","events_url":"https://api.github.com/users/sheriferson/events{/privacy}","received_events_url":"https://api.github.com/users/sheriferson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-04T02:35:37Z","updated_at":"2016-02-04T02:35:37Z","closed_at":null,"body":"`mean` has tests in docstring written above it:\r\n\r\n```\r\n\"\"\"\r\n>>> mean([1])\r\n1.0\r\n>>> mean([1, 2])\r\n1.5\r\n>>> mean([1, 2, 3])\r\n2.0\r\n\"\"\"\r\nmean = lambda data: sum(data) / float(len(data))\r\n```\r\n\r\nbut `doctest` does not detect them:\r\n\r\n``` bash\r\n$ python simple_statistics.py -v\r\n...\r\n3 items had no tests:\r\n    __main__\r\n    __main__.mean\r\n    __main__.standard_deviation\r\n...\r\n```\r\n\r\nThis is because `doctest` only checks\r\n> The module docstring, and all function, class and method docstrings are searched.\r\n\r\nhttps://docs.python.org/2/library/doctest.html#which-docstrings-are-examined\r\n\r\nAnd the docstring that has the tests for `mean` is not [the first line of the module](https://docs.python.org/2/library/doctest.html#which-docstrings-are-examined).\r\n\r\nI 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."}}