@@ -2004,36 +2004,6 @@ def callback(code, instruction_offset):
20042004 sys .monitoring .set_events (0 , 0 )
20052005
20062006
2007- @unittest .skipUnless (hasattr (_testinternalcapi , "new_counter_optimizer" ),
2008- "Requires counter optimizer" )
2009- class TestOptimizer (MonitoringTestBase , unittest .TestCase ):
2010-
2011- def setUp (self ):
2012- if hasattr (_testinternalcapi , "get_optimizer" ):
2013- self .old_opt = _testinternalcapi .get_optimizer ()
2014- opt = _testinternalcapi .new_counter_optimizer ()
2015- _testinternalcapi .set_optimizer (opt )
2016- super (TestOptimizer , self ).setUp ()
2017-
2018- def tearDown (self ):
2019- super (TestOptimizer , self ).tearDown ()
2020- import _testinternalcapi
2021- if hasattr (_testinternalcapi , "get_optimizer" ):
2022- _testinternalcapi .set_optimizer (self .old_opt )
2023-
2024- def test_for_loop (self ):
2025- def test_func (x ):
2026- i = 0
2027- while i < x :
2028- i += 1
2029-
2030- code = test_func .__code__
2031- sys .monitoring .set_local_events (TEST_TOOL , code , E .PY_START )
2032- self .assertEqual (sys .monitoring .get_local_events (TEST_TOOL , code ), E .PY_START )
2033- test_func (1000 )
2034- sys .monitoring .set_local_events (TEST_TOOL , code , 0 )
2035- self .assertEqual (sys .monitoring .get_local_events (TEST_TOOL , code ), 0 )
2036-
20372007class TestTier2Optimizer (CheckEvents ):
20382008
20392009 def test_monitoring_already_opimized_loop (self ):
0 commit comments