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

Method test_two_different

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

Source from the content-addressed store, hash-verified

495 self.assertEqual(sys.monitoring._all_events(), {})
496
497 def test_two_different(self):
498 try:
499 self.assertEqual(sys.monitoring._all_events(), {})
500 counter1 = CounterWithDisable()
501 counter2 = CounterWithDisable()
502 sys.monitoring.register_callback(TEST_TOOL, E.PY_START, counter1)
503 sys.monitoring.register_callback(TEST_TOOL2, E.PY_RETURN, counter2)
504 sys.monitoring.set_events(TEST_TOOL, E.PY_START)
505 sys.monitoring.set_events(TEST_TOOL2, E.PY_RETURN)
506 self.assertEqual(sys.monitoring.get_events(TEST_TOOL), E.PY_START)
507 self.assertEqual(sys.monitoring.get_events(TEST_TOOL2), E.PY_RETURN)
508 self.assertEqual(sys.monitoring._all_events(), {'PY_START': 1 << TEST_TOOL, 'PY_RETURN': 1 << TEST_TOOL2})
509 counter1.count = 0
510 counter2.count = 0
511 f1()
512 count1 = counter1.count
513 count2 = counter2.count
514 self.assertEqual((count1, count2), (1, 1))
515 finally:
516 sys.monitoring.set_events(TEST_TOOL, 0)
517 sys.monitoring.set_events(TEST_TOOL2, 0)
518 sys.monitoring.register_callback(TEST_TOOL, E.PY_START, None)
519 sys.monitoring.register_callback(TEST_TOOL2, E.PY_RETURN, None)
520 self.assertEqual(sys.monitoring._all_events(), {})
521
522 def test_two_with_disable(self):
523 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