sample_doctest.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """This is a sample module that doesn't really test anything all that
  2. interesting.
  3. It simply has a few tests, some of which succeed and some of which fail.
  4. It's important that the numbers remain constant as another test is
  5. testing the running of these tests.
  6. >>> 2+2
  7. 4
  8. """
  9. def foo():
  10. """
  11. >>> 2+2
  12. 5
  13. >>> 2+2
  14. 4
  15. """
  16. def bar():
  17. """
  18. >>> 2+2
  19. 4
  20. """
  21. def test_silly_setup():
  22. """
  23. >>> import test.test_doctest
  24. >>> test.test_doctest.sillySetup
  25. True
  26. """
  27. def w_blank():
  28. """
  29. >>> if 1:
  30. ... print 'a'
  31. ... print
  32. ... print 'b'
  33. a
  34. <BLANKLINE>
  35. b
  36. """
  37. x = 1
  38. def x_is_one():
  39. """
  40. >>> x
  41. 1
  42. """
  43. def y_is_one():
  44. """
  45. >>> y
  46. 1
  47. """
  48. __test__ = {'good': """
  49. >>> 42
  50. 42
  51. """,
  52. 'bad': """
  53. >>> 42
  54. 666
  55. """,
  56. }
  57. def test_suite():
  58. import doctest
  59. return doctest.DocTestSuite()