doctest_lineno.py 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # This module is used in `test_doctest`.
  2. # It must not have a docstring.
  3. def func_with_docstring():
  4. """Some unrelated info."""
  5. def func_without_docstring():
  6. pass
  7. def func_with_doctest():
  8. """
  9. This function really contains a test case.
  10. >>> func_with_doctest.__name__
  11. 'func_with_doctest'
  12. """
  13. return 3
  14. class ClassWithDocstring:
  15. """Some unrelated class information."""
  16. class ClassWithoutDocstring:
  17. pass
  18. class ClassWithDoctest:
  19. """This class really has a test case in it.
  20. >>> ClassWithDoctest.__name__
  21. 'ClassWithDoctest'
  22. """
  23. class MethodWrapper:
  24. def method_with_docstring(self):
  25. """Method with a docstring."""
  26. def method_without_docstring(self):
  27. pass
  28. def method_with_doctest(self):
  29. """
  30. This has a doctest!
  31. >>> MethodWrapper.method_with_doctest.__name__
  32. 'method_with_doctest'
  33. """
  34. # https://github.com/python/cpython/issues/99433
  35. str_wrapper = object().__str__