MCPcopy Create free account
hub / github.com/python/cpython / test_addTests

Method test_addTests

Lib/test/test_unittest/test_suite.py:272–297  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

270 # "This is equivalent to iterating over tests, calling addTest() for
271 # each element"
272 def test_addTests(self):
273 class Foo(unittest.TestCase):
274 def test_1(self): pass
275 def test_2(self): pass
276
277 test_1 = Foo('test_1')
278 test_2 = Foo('test_2')
279 inner_suite = unittest.TestSuite([test_2])
280
281 def gen():
282 yield test_1
283 yield test_2
284 yield inner_suite
285
286 suite_1 = unittest.TestSuite()
287 suite_1.addTests(gen())
288
289 self.assertEqual(list(suite_1), list(gen()))
290
291 # "This is equivalent to iterating over tests, calling addTest() for
292 # each element"
293 suite_2 = unittest.TestSuite()
294 for t in gen():
295 suite_2.addTest(t)
296
297 self.assertEqual(suite_1, suite_2)
298
299 # "Add all the tests from an iterable of TestCase and TestSuite
300 # instances to this test suite."

Callers

nothing calls this directly

Calls 6

listClass · 0.85
addTestsMethod · 0.80
addTestMethod · 0.80
FooClass · 0.70
genFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected