(pytester: Pytester)
| 8 | |
| 9 | |
| 10 | def test_module_and_function_setup(pytester: Pytester) -> None: |
| 11 | reprec = pytester.inline_runsource( |
| 12 | """ |
| 13 | modlevel = [] |
| 14 | def setup_module(module): |
| 15 | assert not modlevel |
| 16 | module.modlevel.append(42) |
| 17 | |
| 18 | def teardown_module(module): |
| 19 | modlevel.pop() |
| 20 | |
| 21 | def setup_function(function): |
| 22 | function.answer = 17 |
| 23 | |
| 24 | def teardown_function(function): |
| 25 | del function.answer |
| 26 | |
| 27 | def test_modlevel(): |
| 28 | assert modlevel[0] == 42 |
| 29 | assert test_modlevel.answer == 17 |
| 30 | |
| 31 | class TestFromClass(object): |
| 32 | def test_module(self): |
| 33 | assert modlevel[0] == 42 |
| 34 | assert not hasattr(test_modlevel, 'answer') |
| 35 | """ |
| 36 | ) |
| 37 | rep = reprec.matchreport("test_modlevel") |
| 38 | assert rep.passed |
| 39 | rep = reprec.matchreport("test_module") |
| 40 | assert rep.passed |
| 41 | |
| 42 | |
| 43 | def test_module_setup_failure_no_teardown(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…