(self)
| 462 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 463 | |
| 464 | def test_three_same(self): |
| 465 | try: |
| 466 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 467 | counter1 = CounterWithDisable() |
| 468 | counter2 = CounterWithDisable() |
| 469 | counter3 = CounterWithDisable() |
| 470 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, counter1) |
| 471 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, counter2) |
| 472 | sys.monitoring.register_callback(TEST_TOOL3, E.PY_START, counter3) |
| 473 | sys.monitoring.set_events(TEST_TOOL, E.PY_START) |
| 474 | sys.monitoring.set_events(TEST_TOOL2, E.PY_START) |
| 475 | sys.monitoring.set_events(TEST_TOOL3, E.PY_START) |
| 476 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL), E.PY_START) |
| 477 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL2), E.PY_START) |
| 478 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL3), E.PY_START) |
| 479 | self.assertEqual(sys.monitoring._all_events(), {'PY_START': (1 << TEST_TOOL) | (1 << TEST_TOOL2) | (1 << TEST_TOOL3)}) |
| 480 | counter1.count = 0 |
| 481 | counter2.count = 0 |
| 482 | counter3.count = 0 |
| 483 | f1() |
| 484 | count1 = counter1.count |
| 485 | count2 = counter2.count |
| 486 | count3 = counter3.count |
| 487 | self.assertEqual((count1, count2, count3), (1, 1, 1)) |
| 488 | finally: |
| 489 | sys.monitoring.set_events(TEST_TOOL, 0) |
| 490 | sys.monitoring.set_events(TEST_TOOL2, 0) |
| 491 | sys.monitoring.set_events(TEST_TOOL3, 0) |
| 492 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, None) |
| 493 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, None) |
| 494 | sys.monitoring.register_callback(TEST_TOOL3, E.PY_START, None) |
| 495 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 496 | |
| 497 | def test_two_different(self): |
| 498 | try: |
nothing calls this directly
no test coverage detected