MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_two_same

Method test_two_same

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

Source from the content-addressed store, hash-verified

443class MultipleMonitorsTest(MonitoringTestBase, unittest.TestCase):
444
445 def test_two_same(self):
446 try:
447 self.assertEqual(sys.monitoring._all_events(), {})
448 counter1 = CounterWithDisable()
449 counter2 = CounterWithDisable()
450 sys.monitoring.register_callback(TEST_TOOL, E.PY_START, counter1)
451 sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, counter2)
452 sys.monitoring.set_events(TEST_TOOL, E.PY_START)
453 sys.monitoring.set_events(TEST_TOOL2, E.PY_START)
454 self.assertEqual(sys.monitoring.get_events(TEST_TOOL), E.PY_START)
455 self.assertEqual(sys.monitoring.get_events(TEST_TOOL2), E.PY_START)
456 self.assertEqual(sys.monitoring._all_events(), {'PY_START': (1 << TEST_TOOL) | (1 << TEST_TOOL2)})
457 counter1.count = 0
458 counter2.count = 0
459 f1()
460 count1 = counter1.count
461 count2 = counter2.count
462 self.assertEqual((count1, count2), (1, 1))
463 finally:
464 sys.monitoring.set_events(TEST_TOOL, 0)
465 sys.monitoring.set_events(TEST_TOOL2, 0)
466 sys.monitoring.register_callback(TEST_TOOL, E.PY_START, None)
467 sys.monitoring.register_callback(TEST_TOOL2, E.PY_START, None)
468 self.assertEqual(sys.monitoring._all_events(), {})
469
470 def test_three_same(self):
471 try:

Callers

nothing calls this directly

Calls 4

CounterWithDisableClass · 0.85
f1Function · 0.70
assertEqualMethod · 0.45
get_eventsMethod · 0.45

Tested by

no test coverage detected