item.obj should be a bound method on unittest.TestCase function items (#5390).
(pytester: Pytester)
| 144 | |
| 145 | |
| 146 | def test_function_item_obj_is_instance(pytester: Pytester) -> None: |
| 147 | """item.obj should be a bound method on unittest.TestCase function items (#5390).""" |
| 148 | pytester.makeconftest( |
| 149 | """ |
| 150 | def pytest_runtest_makereport(item, call): |
| 151 | if call.when == 'call': |
| 152 | class_ = item.parent.obj |
| 153 | assert isinstance(item.obj.__self__, class_) |
| 154 | """ |
| 155 | ) |
| 156 | pytester.makepyfile( |
| 157 | """ |
| 158 | import unittest |
| 159 | |
| 160 | class Test(unittest.TestCase): |
| 161 | def test_foo(self): |
| 162 | pass |
| 163 | """ |
| 164 | ) |
| 165 | result = pytester.runpytest_inprocess() |
| 166 | result.stdout.fnmatch_lines(["* 1 passed in*"]) |
| 167 | |
| 168 | |
| 169 | def test_teardown(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected