(self)
| 1452 | self.assertEqual(log, []) |
| 1453 | |
| 1454 | def test_check_warnings(self): |
| 1455 | # Explicit tests for the test.support convenience wrapper |
| 1456 | wmod = self.module |
| 1457 | if wmod is not sys.modules['warnings']: |
| 1458 | self.skipTest('module to test is not loaded warnings module') |
| 1459 | with warnings_helper.check_warnings(quiet=False) as w: |
| 1460 | self.assertEqual(w.warnings, []) |
| 1461 | wmod.simplefilter("always") |
| 1462 | wmod.warn("foo") |
| 1463 | self.assertEqual(str(w.message), "foo") |
| 1464 | wmod.warn("bar") |
| 1465 | self.assertEqual(str(w.message), "bar") |
| 1466 | self.assertEqual(str(w.warnings[0].message), "foo") |
| 1467 | self.assertEqual(str(w.warnings[1].message), "bar") |
| 1468 | w.reset() |
| 1469 | self.assertEqual(w.warnings, []) |
| 1470 | |
| 1471 | with warnings_helper.check_warnings(): |
| 1472 | # defaults to quiet=True without argument |
| 1473 | pass |
| 1474 | with warnings_helper.check_warnings(('foo', UserWarning)): |
| 1475 | wmod.warn("foo") |
| 1476 | |
| 1477 | with self.assertRaises(AssertionError): |
| 1478 | with warnings_helper.check_warnings(('', RuntimeWarning)): |
| 1479 | # defaults to quiet=False with argument |
| 1480 | pass |
| 1481 | with self.assertRaises(AssertionError): |
| 1482 | with warnings_helper.check_warnings(('foo', RuntimeWarning)): |
| 1483 | wmod.warn("foo") |
| 1484 | |
| 1485 | class CCatchWarningTests(CatchWarningTests, unittest.TestCase): |
| 1486 | module = c_warnings |
nothing calls this directly
no test coverage detected