MCPcopy Index your code
hub / github.com/python/cpython / test_two_same

Method test_two_same

Lib/test/test_monitoring.py:439–462  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

437class 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:

Callers

nothing calls this directly

Calls 5

CounterWithDisableClass · 0.85
f1Function · 0.85
assertEqualMethod · 0.45
register_callbackMethod · 0.45
get_eventsMethod · 0.45

Tested by

no test coverage detected