MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_function_item_obj_is_instance

Function test_function_item_obj_is_instance

testing/test_unittest.py:146–166  ·  view source on GitHub ↗

item.obj should be a bound method on unittest.TestCase function items (#5390).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

144
145
146def 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
169def test_teardown(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
makeconftestMethod · 0.45
makepyfileMethod · 0.45
runpytest_inprocessMethod · 0.45

Tested by

no test coverage detected