/
test_example2.py
57 lines (42 loc) · 1.1 KB
/
test_example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""pytest file built from doc/example2.md"""
from phmdoctest.functions import _phm_compare_exact
def test_code_9_output_14(capsys):
squares = [1, 4, 9, 16, 25]
print(squares)
_phm_expected_str = """\
[1, 4, 9, 16, 25]
"""
_phm_compare_exact(a=_phm_expected_str, b=capsys.readouterr().out)
def test_code_37():
a, b = 0, 1
while a < 1000:
print(a, end=",")
a, b = b, a + b
# Caution- no assertions.
def test_code_44_output_51(capsys):
words = ["cat", "window", "defenestrate"]
for w in words:
print(w, len(w))
_phm_expected_str = """\
cat 3
window 6
defenestrate 12
"""
_phm_compare_exact(a=_phm_expected_str, b=capsys.readouterr().out)
def session_00001_line_75():
r"""
>>> a = "Greetings Planet!"
>>> a
'Greetings Planet!'
>>> b = 12
>>> b
12
"""
def test_code_87_output_94(capsys):
from datetime import date
d = date.fromordinal(730920) # 730920th day after 1. 1. 0001
print(d)
_phm_expected_str = """\
2002-03-11
"""
_phm_compare_exact(a=_phm_expected_str, b=capsys.readouterr().out)