Fix expectations for get_func_args() on 3.13.

This commit is contained in:
Andrey Rakhmatullin 2024-09-20 19:28:28 +05:00
parent ee9ee2d12d
commit e139d22db9
1 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import functools
import operator
import platform
import sys
from twisted.trial import unittest
@ -238,16 +239,18 @@ class UtilsPythonTestCase(unittest.TestCase):
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"]
)
def test_without_none_values(self):
self.assertEqual(without_none_values([1, None, 3, 4]), [1, 3, 4])