nimi-python icon indicating copy to clipboard operation
nimi-python copied to clipboard

Consider using doctest

Open thejcannon opened this issue 6 years ago • 0 comments

pytest has doctest integration: http://doc.pytest.org/en/latest/doctest.html

High-level, for code (most likely utilities) you can add little examples in the docstring which help document the utility in an unambiguous fashion. doctest will turn those snippets into tests, ensuring what is written is true.

E.g.

def add(x, y):
   """Adds the numbers.
      >>> add(1, 2)
      4
   """

Would become a failing test at test time.

thejcannon avatar Feb 27 '20 21:02 thejcannon