-
Notifications
You must be signed in to change notification settings - Fork 1
/
readme_test.py
42 lines (30 loc) · 982 Bytes
/
readme_test.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
# SPDX-FileCopyrightText: 2024 Johann Klähn <[email protected]>
#
# SPDX-License-Identifier: MIT
import readme as m
def test_readme_example(capsys):
obj = m.Example()
assert obj.something == 0
obj.something = 42
assert obj.something == 42
assert obj.calculate() == -42 # default argument
assert obj.calculate(m.Flavor.bland) == 42
assert m.Example.__doc__ == "A contrived example."
print(m.Flavor.__doc__)
output = capsys.readouterr()
expected = """\
Describes how the output will taste.
Members:
bland : Like you would expect.
fruity : It tastes different.
"""
assert output.out == expected
help(obj.calculate)
output = capsys.readouterr()
expected = """\
Help on method calculate in module readme:
calculate(...) method of readme.Example instance
calculate(self: readme.Example, flavor: readme.Flavor = <Flavor.fruity: 1>) -> int
Do a complicated calculation.
"""
assert output.out == expected