(pytester: Pytester)
| 64 | |
| 65 | |
| 66 | def test_setup(pytester: Pytester) -> None: |
| 67 | testpath = pytester.makepyfile( |
| 68 | """ |
| 69 | import unittest |
| 70 | class MyTestCase(unittest.TestCase): |
| 71 | def setUp(self): |
| 72 | self.foo = 1 |
| 73 | def setup_method(self, method): |
| 74 | self.foo2 = 1 |
| 75 | def test_both(self): |
| 76 | self.assertEqual(1, self.foo) |
| 77 | assert self.foo2 == 1 |
| 78 | def teardown_method(self, method): |
| 79 | assert 0, "42" |
| 80 | |
| 81 | """ |
| 82 | ) |
| 83 | reprec = pytester.inline_run("-s", testpath) |
| 84 | assert reprec.matchreport("test_both", when="call").passed |
| 85 | rep = reprec.matchreport("test_both", when="teardown") |
| 86 | assert rep.failed and "42" in str(rep.longrepr) |
| 87 | |
| 88 | |
| 89 | def test_setUpModule(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected