I like using doctest for python3 to write tests. It looks like this
Then you can use
python3 -m doctests blah.py
and it will run
add(5,6) and compare it to
11. Great easy inline tests just like rust.
The problem is in a case like this
doctest won’t be able to find that there is a docstring on the add function because the decorator threw through it away here:
All we have to do is add one line
inner.__doc__ = _func.__doc__
to our decorator and we can preserve it.