Skip to content
Snippets Groups Projects
Commit 61d915e7 authored by Stuart Prescott's avatar Stuart Prescott
Browse files

Cherry-pick patch for Python 3.13

Closes: #1082257
parent 9b28baed
No related branches found
No related tags found
No related merge requests found
commit 02c655d4f7a6e12351437cdbc26e07cd64716953
Author: Ayala Shachar <shachar.ayala@gmail.com>
Date: Wed Oct 2 22:24:54 2024 +0300
Fix unittests for python3.13
diff --git a/tests/test__signature_object.py b/tests/test__signature_object.py
index 304b104..1415a60 100644
--- a/tests/test__signature_object.py
+++ b/tests/test__signature_object.py
@@ -1,4 +1,5 @@
import time
+import sys
from .ut_utils import TestCase
from forge.signature import FunctionSignature
from forge.exceptions import SignatureException, InvalidKeywordArgument, FunctionCannotBeBound
@@ -126,11 +127,26 @@ class SignatureTest(TestCase):
self.assertIsNot(f._args, f2._args)
class BinaryFunctionSignatureTest(TestCase):
- def test__binary_global_function(self):
+ def test__binary_global_function_with_no_parameters(self):
sig = FunctionSignature(time.time)
self.assertEqual(sig._args, [])
- self.assertTrue(sig.has_variable_args())
- self.assertTrue(sig.has_variable_kwargs())
+ if sys.version_info[:2] < (3, 13):
+ self.assertTrue(sig.has_variable_args())
+ self.assertTrue(sig.has_variable_kwargs())
+ else:
+ # Starting 3.13, inspect succeed (not raise TypeError) for buildin functions, like `time.time`
+ self.assertFalse(sig.has_variable_args())
+ self.assertFalse(sig.has_variable_kwargs())
+ def test__binary_global_function_with_parameters(self):
+ sig = FunctionSignature(time.sleep)
+ if sys.version_info[:2] < (3, 13):
+ self.assertEqual(sig._args, [])
+ self.assertTrue(sig.has_variable_args())
+ self.assertTrue(sig.has_variable_kwargs())
+ else:
+ self.assertEqual(len(sig._args), 1)
+ self.assertFalse(sig.has_variable_args())
+ self.assertFalse(sig.has_variable_kwargs())
def test__object_method_placeholders(self):
class SomeObject(object):
pass
pyver.patch
tox-pytest.patch
python3.13.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment