Skip to content

Instantly share code, notes, and snippets.

@akun
Created April 28, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akun/c7c8a13bfc38bb643ff9677c914867d7 to your computer and use it in GitHub Desktop.
Save akun/c7c8a13bfc38bb643ff9677c914867d7 to your computer and use it in GitHub Desktop.
x.md

x.py

def add(a, b):                                                                  
    return a + b

case.txt

>>> from x import add                                                           
>>> add(1, 2)                                                                   
3                                                                               
>>> add(3, 97)                                                                  
100                                                                             
>>> add(3, 3) != 5                                                              
True

In Shell

$ python -m doctest -v case.txt
Trying:
    from x import add
Expecting nothing
ok
Trying:
    add(1, 2)
Expecting:
    3
ok
Trying:
    add(3, 97)
Expecting:
    100
ok
Trying:
    add(3, 3) != 5
Expecting:
    True
ok
1 items passed all tests:
   4 tests in case.txt
4 tests in 1 items.
4 passed and 0 failed.
Test passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment