Skip to content

Commit 76bf5a1

Browse files
committed
Fix expectations for get_func_args() on 3.13.
1 parent e8237ed commit 76bf5a1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/test_utils_python.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import operator
33
import platform
4+
import sys
45
import unittest
56
from typing import Any
67

@@ -48,16 +49,18 @@ def __call__(self, a, b, c):
4849
self.assertEqual(get_func_args(str.split, stripself=True), ["sep", "maxsplit"])
4950
self.assertEqual(get_func_args(" ".join, stripself=True), ["iterable"])
5051

51-
if platform.python_implementation() == "CPython":
52-
# This didn't work on older versions of CPython: https://github.com/python/cpython/issues/86951
52+
if sys.version_info >= (3, 13) or platform.python_implementation() == "PyPy":
53+
# the correct and correctly extracted signature
54+
self.assertEqual(
55+
get_func_args(operator.itemgetter(2), stripself=True), ["obj"]
56+
)
57+
elif platform.python_implementation() == "CPython":
58+
# ["args", "kwargs"] is a correct result for the pre-3.13 incorrect function signature
59+
# [] is an incorrect result on even older CPython (https://github.com/python/cpython/issues/86951)
5360
self.assertIn(
5461
get_func_args(operator.itemgetter(2), stripself=True),
5562
[[], ["args", "kwargs"]],
5663
)
57-
elif platform.python_implementation() == "PyPy":
58-
self.assertEqual(
59-
get_func_args(operator.itemgetter(2), stripself=True), ["obj"]
60-
)
6164

6265

6366
if __name__ == "__main__":

0 commit comments

Comments
 (0)