diff options
| author | Mark Shannon <mark@hotpy.org> | 2022-05-04 15:31:21 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-04 15:31:21 (GMT) |
| commit | f8a2fab212c4e9ea92a5b667560449904c4cf7af (patch) | |
| tree | dc6c40594f776bd7d262a1b915661c253acc92d3 /Lib/test/test_capi.py | |
| parent | 9d20e1af409c22537f096206edd330f16ab8f1f3 (diff) | |
| download | cpython-f8a2fab212c4e9ea92a5b667560449904c4cf7af.zip cpython-f8a2fab212c4e9ea92a5b667560449904c4cf7af.tar.gz cpython-f8a2fab212c4e9ea92a5b667560449904c4cf7af.tar.bz2 | |
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245)
Diffstat (limited to 'Lib/test/test_capi.py')
| -rw-r--r-- | Lib/test/test_capi.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 1aed9b7..ab4caef 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -1142,5 +1142,33 @@ class Test_FrameAPI(unittest.TestCase): self.assertIs(gen, _testcapi.frame_getgenerator(frame)) +SUFFICIENT_TO_DEOPT_AND_SPECIALIZE = 100 + +class Test_Pep523API(unittest.TestCase): + + def do_test(self, func): + calls = [] + start = SUFFICIENT_TO_DEOPT_AND_SPECIALIZE + count = start + SUFFICIENT_TO_DEOPT_AND_SPECIALIZE + for i in range(count): + if i == start: + _testinternalcapi.set_eval_frame_record(calls) + func() + _testinternalcapi.set_eval_frame_default() + self.assertEqual(len(calls), SUFFICIENT_TO_DEOPT_AND_SPECIALIZE) + for name in calls: + self.assertEqual(name, func.__name__) + + def test_pep523_with_specialization_simple(self): + def func1(): + pass + self.do_test(func1) + + def test_pep523_with_specialization_with_default(self): + def func2(x=None): + pass + self.do_test(func2) + + if __name__ == "__main__": unittest.main() |
