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