Skip to content

Commit

Permalink
Fix expectations for get_func_args() on 3.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Sep 20, 2024
1 parent e8237ed commit 76bf5a1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/test_utils_python.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import operator
import platform
import sys
import unittest
from typing import Any

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

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


if __name__ == "__main__":
Expand Down

0 comments on commit 76bf5a1

Please sign in to comment.