(self)
| 520 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 521 | |
| 522 | def test_two_with_disable(self): |
| 523 | try: |
| 524 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 525 | counter1 = CounterWithDisable() |
| 526 | counter2 = CounterWithDisable() |
| 527 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, counter1) |
| 528 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, counter2) |
| 529 | sys.monitoring.set_events(TEST_TOOL, E.PY_START) |
| 530 | sys.monitoring.set_events(TEST_TOOL2, E.PY_START) |
| 531 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL), E.PY_START) |
| 532 | self.assertEqual(sys.monitoring.get_events(TEST_TOOL2), E.PY_START) |
| 533 | self.assertEqual(sys.monitoring._all_events(), {'PY_START': (1 << TEST_TOOL) | (1 << TEST_TOOL2)}) |
| 534 | counter1.count = 0 |
| 535 | counter2.count = 0 |
| 536 | counter1.disable = True |
| 537 | f1() |
| 538 | count1 = counter1.count |
| 539 | count2 = counter2.count |
| 540 | self.assertEqual((count1, count2), (1, 1)) |
| 541 | counter1.count = 0 |
| 542 | counter2.count = 0 |
| 543 | f1() |
| 544 | count1 = counter1.count |
| 545 | count2 = counter2.count |
| 546 | self.assertEqual((count1, count2), (0, 1)) |
| 547 | finally: |
| 548 | sys.monitoring.set_events(TEST_TOOL, 0) |
| 549 | sys.monitoring.set_events(TEST_TOOL2, 0) |
| 550 | sys.monitoring.register_callback(TEST_TOOL, E.PY_START, None) |
| 551 | sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, None) |
| 552 | self.assertEqual(sys.monitoring._all_events(), {}) |
| 553 | sys.monitoring.restart_events() |
| 554 | |
| 555 | def test_with_instruction_event(self): |
| 556 | """Test that the second tool can set events with instruction events set by the first tool.""" |
nothing calls this directly
no test coverage detected