GH-104584: Plugin optimizer API (GH-105100)

This commit is contained in:
Mark Shannon 2023-06-02 11:46:18 +01:00 committed by GitHub
parent 601ae09f0c
commit 4bfa01b9d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 950 additions and 501 deletions

View file

@ -1916,6 +1916,19 @@ class Test_Pep523API(unittest.TestCase):
names = ["func", "outer", "outer", "inner", "inner", "outer", "inner"]
self.do_test(func, names)
class TestOptimizerAPI(unittest.TestCase):
def test_counter_optimizer(self):
opt = _testinternalcapi.get_counter_optimizer()
self.assertEqual(opt.get_count(), 0)
try:
_testinternalcapi.set_optimizer(opt)
self.assertEqual(opt.get_count(), 0)
for _ in range(1000):
pass
self.assertEqual(opt.get_count(), 1000)
finally:
_testinternalcapi.set_optimizer(None)
if __name__ == "__main__":
unittest.main()