Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
154cc588
Commit
154cc588
authored
Aug 23, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1594966: fix misleading usage example
parent
3e0f735c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
16 deletions
+4
-16
Doc/library/doctest.rst
Doc/library/doctest.rst
+4
-16
No files found.
Doc/library/doctest.rst
View file @
154cc588
...
...
@@ -69,11 +69,6 @@ Here's a complete but small example module::
OverflowError: n too large
"""
.. % allow LaTeX to break here.
::
import math
if not n >= 0:
raise ValueError("n must be >= 0")
...
...
@@ -88,12 +83,10 @@ Here's a complete but small example module::
factor += 1
return result
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
import doctest
doctest.testmod()
If you run :file:`example.py` directly from the command line, :mod:`doctest`
works its magic::
...
...
@@ -131,12 +124,10 @@ And so on, eventually ending with::
...
OverflowError: n too large
ok
1 items had no tests:
__main__._test
2 items passed all tests:
1 tests in __main__
8 tests in __main__.factorial
9 tests in
3
items.
9 tests in
2
items.
9 passed and 0 failed.
Test passed.
$
...
...
@@ -156,13 +147,10 @@ Simple Usage: Checking Examples in Docstrings
The simplest way to start using doctest (but not necessarily the way you'll
continue to do it) is to end each module :mod:`M` with::
def _test()
:
if __name__ == "__main__"
:
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
:mod:`doctest` then examines docstrings in module :mod:`M`.
Running the module as a script causes the examples in the docstrings to get
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment