(self)
| 437 | class MultipleMonitorsTest(MonitoringTestBase, unittest.TestCase): |
| 438 | |
| 439 | def test_two_same(self): |
| 440 | try: |
| 441 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 442 | counter1 = CounterWithDisable() |
| 443 | counter2 = CounterWithDisable() |
| 444 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, counter1) |
| 445 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, counter2) |
| 446 | sys.monitoring.set_events(TEST_TOOL, E.PY_START) |
| 447 | sys.monitoring.set_events(TEST_TOOL2, E.PY_START) |
| 448 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL), E.PY_START) |
| 449 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL2), E.PY_START) |
| 450 | self.assertEqual(sys.monitoring._all_events(), {'PY_START': (1 << TEST_TOOL) | (1 << TEST_TOOL2)}) |
| 451 | counter1.count = 0 |
| 452 | counter2.count = 0 |
| 453 | f1() |
| 454 | count1 = counter1.count |
| 455 | count2 = counter2.count |
| 456 | self.assertEqual((count1, count2), (1, 1)) |
| 457 | finally: |
| 458 | sys.monitoring.set_events(TEST_TOOL, 0) |
| 459 | sys.monitoring.set_events(TEST_TOOL2, 0) |
| 460 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, None) |
| 461 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, None) |
| 462 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 463 | |
| 464 | def test_three_same(self): |
| 465 | try: |
nothing calls this directly
no test coverage detected