mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Merging from tim-doctest-branch, which is now closed.
This primarily adds more powerful ways to work with unittest, including spiffy support for building suites out of doctests in non-Python "text files".
This commit is contained in:
parent
98bd1814e2
commit
19397e5ec5
5 changed files with 919 additions and 182 deletions
66
Lib/test/sample_doctest.py
Normal file
66
Lib/test/sample_doctest.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
"""This is a sample module that doesn't really test anything all that
|
||||
interesting
|
||||
|
||||
It simply has a few tests, some of which suceed and some of which fail.
|
||||
|
||||
It's important that the numbers remain constance, as another test is
|
||||
testing the running of these tests.
|
||||
|
||||
|
||||
>>> 2+2
|
||||
4
|
||||
"""
|
||||
|
||||
|
||||
def foo():
|
||||
"""
|
||||
|
||||
>>> 2+2
|
||||
5
|
||||
|
||||
>>> 2+2
|
||||
4
|
||||
"""
|
||||
|
||||
def bar():
|
||||
"""
|
||||
|
||||
>>> 2+2
|
||||
4
|
||||
"""
|
||||
|
||||
def test_silly_setup():
|
||||
"""
|
||||
|
||||
>>> import test.test_doctest
|
||||
>>> test.test_doctest.sillySetup
|
||||
True
|
||||
"""
|
||||
|
||||
def w_blank():
|
||||
"""
|
||||
>>> if 1:
|
||||
... print 'a'
|
||||
... print
|
||||
... print 'b'
|
||||
a
|
||||
<BLANKLINE>
|
||||
b
|
||||
"""
|
||||
|
||||
x = 1
|
||||
def x_is_one():
|
||||
"""
|
||||
>>> x
|
||||
1
|
||||
"""
|
||||
|
||||
def y_is_one():
|
||||
"""
|
||||
>>> y
|
||||
1
|
||||
"""
|
||||
|
||||
def test_suite():
|
||||
import doctest
|
||||
return doctest.DocTestSuite()
|
Loading…
Add table
Add a link
Reference in a new issue