mirror of
https://github.com/python/cpython.git
synced 2025-11-11 02:52:04 +00:00
[3.14] gh-108885: Imporove tests for doctest (GH-134832) (GH-134855)
Test the error and failure report in more detail.
(cherry picked from commit f6324bc7ee)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
381144f043
commit
52bae918c3
5 changed files with 545 additions and 8 deletions
46
Lib/test/test_doctest/sample_doctest_errors.py
Normal file
46
Lib/test/test_doctest/sample_doctest_errors.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""This is a sample module used for testing doctest.
|
||||
|
||||
This module includes various scenarios involving errors.
|
||||
|
||||
>>> 2 + 2
|
||||
5
|
||||
>>> 1/0
|
||||
1
|
||||
"""
|
||||
|
||||
def g():
|
||||
[][0] # line 12
|
||||
|
||||
def errors():
|
||||
"""
|
||||
>>> 2 + 2
|
||||
5
|
||||
>>> 1/0
|
||||
1
|
||||
>>> def f():
|
||||
... 2 + '2'
|
||||
...
|
||||
>>> f()
|
||||
1
|
||||
>>> g()
|
||||
1
|
||||
"""
|
||||
|
||||
def syntax_error():
|
||||
"""
|
||||
>>> 2+*3
|
||||
5
|
||||
"""
|
||||
|
||||
__test__ = {
|
||||
'bad': """
|
||||
>>> 2 + 2
|
||||
5
|
||||
>>> 1/0
|
||||
1
|
||||
""",
|
||||
}
|
||||
|
||||
def test_suite():
|
||||
import doctest
|
||||
return doctest.DocTestSuite()
|
||||
Loading…
Add table
Add a link
Reference in a new issue