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

Function test_teardown

testing/test_unittest.py:169–188  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

167
168
169def test_teardown(pytester: Pytester) -> None:
170 testpath = pytester.makepyfile(
171 """
172 import unittest
173 class MyTestCase(unittest.TestCase):
174 values = []
175 def test_one(self):
176 pass
177 def tearDown(self):
178 self.values.append(None)
179 class Second(unittest.TestCase):
180 def test_check(self):
181 self.assertEqual(MyTestCase.values, [None])
182 """
183 )
184 reprec = pytester.inline_run(testpath)
185 passed, skipped, failed = reprec.countoutcomes()
186 assert failed == 0, failed
187 assert passed == 2
188 assert passed + skipped + failed == 2
189
190
191def test_teardown_issue1649(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

countoutcomesMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected