mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)
(cherry picked from commit 2602d8ae98
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
d5f7e80d44
commit
db98e0bb12
117 changed files with 407 additions and 445 deletions
|
@ -786,12 +786,12 @@ class TestRetrievingSourceCode(GetSourceBase):
|
|||
def test_getfile_builtin_module(self):
|
||||
with self.assertRaises(TypeError) as e:
|
||||
inspect.getfile(sys)
|
||||
self.assertTrue(str(e.exception).startswith('<module'))
|
||||
self.assertStartsWith(str(e.exception), '<module')
|
||||
|
||||
def test_getfile_builtin_class(self):
|
||||
with self.assertRaises(TypeError) as e:
|
||||
inspect.getfile(int)
|
||||
self.assertTrue(str(e.exception).startswith('<class'))
|
||||
self.assertStartsWith(str(e.exception), '<class')
|
||||
|
||||
def test_getfile_builtin_function_or_method(self):
|
||||
with self.assertRaises(TypeError) as e_abs:
|
||||
|
@ -2949,7 +2949,7 @@ class TestSignatureObject(unittest.TestCase):
|
|||
pass
|
||||
|
||||
sig = inspect.signature(test)
|
||||
self.assertTrue(repr(sig).startswith('<Signature'))
|
||||
self.assertStartsWith(repr(sig), '<Signature')
|
||||
self.assertTrue('(po, /, pk' in repr(sig))
|
||||
|
||||
# We need two functions, because it is impossible to represent
|
||||
|
@ -2958,7 +2958,7 @@ class TestSignatureObject(unittest.TestCase):
|
|||
pass
|
||||
|
||||
sig2 = inspect.signature(test2)
|
||||
self.assertTrue(repr(sig2).startswith('<Signature'))
|
||||
self.assertStartsWith(repr(sig2), '<Signature')
|
||||
self.assertTrue('(pod=42, /)' in repr(sig2))
|
||||
|
||||
po = sig.parameters['po']
|
||||
|
@ -5102,7 +5102,7 @@ class TestParameterObject(unittest.TestCase):
|
|||
with self.assertRaisesRegex(ValueError, 'cannot have default values'):
|
||||
p.replace(kind=inspect.Parameter.VAR_POSITIONAL)
|
||||
|
||||
self.assertTrue(repr(p).startswith('<Parameter'))
|
||||
self.assertStartsWith(repr(p), '<Parameter')
|
||||
self.assertTrue('"a=42"' in repr(p))
|
||||
|
||||
def test_signature_parameter_hashable(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue