|
1 | 1 | import time
|
| 2 | +import sys |
2 | 3 | from .ut_utils import TestCase
|
3 | 4 | from forge.signature import FunctionSignature
|
4 | 5 | from forge.exceptions import SignatureException, InvalidKeywordArgument, FunctionCannotBeBound
|
@@ -126,11 +127,26 @@ def test__copy(self):
|
126 | 127 | self.assertIsNot(f._args, f2._args)
|
127 | 128 |
|
128 | 129 | class BinaryFunctionSignatureTest(TestCase):
|
129 |
| - def test__binary_global_function(self): |
| 130 | + def test__binary_global_function_with_no_parameters(self): |
130 | 131 | sig = FunctionSignature(time.time)
|
131 | 132 | self.assertEqual(sig._args, [])
|
132 |
| - self.assertTrue(sig.has_variable_args()) |
133 |
| - self.assertTrue(sig.has_variable_kwargs()) |
| 133 | + if sys.version_info[:2] < (3, 13): |
| 134 | + self.assertTrue(sig.has_variable_args()) |
| 135 | + self.assertTrue(sig.has_variable_kwargs()) |
| 136 | + else: |
| 137 | + # Starting 3.13, inspect succeed (not raise TypeError) for buildin functions, like `time.time` |
| 138 | + self.assertFalse(sig.has_variable_args()) |
| 139 | + self.assertFalse(sig.has_variable_kwargs()) |
| 140 | + def test__binary_global_function_with_parameters(self): |
| 141 | + sig = FunctionSignature(time.sleep) |
| 142 | + if sys.version_info[:2] < (3, 13): |
| 143 | + self.assertEqual(sig._args, []) |
| 144 | + self.assertTrue(sig.has_variable_args()) |
| 145 | + self.assertTrue(sig.has_variable_kwargs()) |
| 146 | + else: |
| 147 | + self.assertEqual(len(sig._args), 1) |
| 148 | + self.assertFalse(sig.has_variable_args()) |
| 149 | + self.assertFalse(sig.has_variable_kwargs()) |
134 | 150 | def test__object_method_placeholders(self):
|
135 | 151 | class SomeObject(object):
|
136 | 152 | pass
|
|
0 commit comments