simple.py 727 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Simple example using doctests.
  2. This file just contains doctests both using plain python and IPython prompts.
  3. All tests should be loaded by Pytest.
  4. """
  5. def pyfunc():
  6. """Some pure python tests...
  7. >>> pyfunc()
  8. 'pyfunc'
  9. >>> import os
  10. >>> 2+3
  11. 5
  12. >>> for i in range(3):
  13. ... print(i, end=' ')
  14. ... print(i+1, end=' ')
  15. ...
  16. 0 1 1 2 2 3
  17. """
  18. return 'pyfunc'
  19. def ipyfunc():
  20. """Some IPython tests...
  21. In [1]: ipyfunc()
  22. Out[1]: 'ipyfunc'
  23. In [2]: import os
  24. In [3]: 2+3
  25. Out[3]: 5
  26. In [4]: for i in range(3):
  27. ...: print(i, end=' ')
  28. ...: print(i+1, end=' ')
  29. ...:
  30. Out[4]: 0 1 1 2 2 3
  31. """
  32. return "ipyfunc"