Skip to content

Commit 52bae91

Browse files
[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 f6324bc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 381144f commit 52bae91

File tree

5 files changed

+545
-8
lines changed

5 files changed

+545
-8
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""This is a sample module used for testing doctest.
2+
3+
This module includes various scenarios involving errors.
4+
5+
>>> 2 + 2
6+
5
7+
>>> 1/0
8+
1
9+
"""
10+
11+
def g():
12+
[][0] # line 12
13+
14+
def errors():
15+
"""
16+
>>> 2 + 2
17+
5
18+
>>> 1/0
19+
1
20+
>>> def f():
21+
... 2 + '2'
22+
...
23+
>>> f()
24+
1
25+
>>> g()
26+
1
27+
"""
28+
29+
def syntax_error():
30+
"""
31+
>>> 2+*3
32+
5
33+
"""
34+
35+
__test__ = {
36+
'bad': """
37+
>>> 2 + 2
38+
5
39+
>>> 1/0
40+
1
41+
""",
42+
}
43+
44+
def test_suite():
45+
import doctest
46+
return doctest.DocTestSuite()

0 commit comments

Comments
 (0)