mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +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
|
|
@ -275,12 +275,12 @@ def test_alias(self):
|
|||
self.assertEqual(alias.end_col_offset, 17)
|
||||
|
||||
def test_base_classes(self):
|
||||
self.assertTrue(issubclass(ast.For, ast.stmt))
|
||||
self.assertTrue(issubclass(ast.Name, ast.expr))
|
||||
self.assertTrue(issubclass(ast.stmt, ast.AST))
|
||||
self.assertTrue(issubclass(ast.expr, ast.AST))
|
||||
self.assertTrue(issubclass(ast.comprehension, ast.AST))
|
||||
self.assertTrue(issubclass(ast.Gt, ast.AST))
|
||||
self.assertIsSubclass(ast.For, ast.stmt)
|
||||
self.assertIsSubclass(ast.Name, ast.expr)
|
||||
self.assertIsSubclass(ast.stmt, ast.AST)
|
||||
self.assertIsSubclass(ast.expr, ast.AST)
|
||||
self.assertIsSubclass(ast.comprehension, ast.AST)
|
||||
self.assertIsSubclass(ast.Gt, ast.AST)
|
||||
|
||||
def test_field_attr_existence(self):
|
||||
for name, item in ast.__dict__.items():
|
||||
|
|
@ -1101,7 +1101,7 @@ def test_copy_with_parents(self):
|
|||
def test_replace_interface(self):
|
||||
for klass in self.iter_ast_classes():
|
||||
with self.subTest(klass=klass):
|
||||
self.assertTrue(hasattr(klass, '__replace__'))
|
||||
self.assertHasAttr(klass, '__replace__')
|
||||
|
||||
fields = set(klass._fields)
|
||||
with self.subTest(klass=klass, fields=fields):
|
||||
|
|
@ -1330,7 +1330,7 @@ def test_replace_reject_known_custom_instance_fields_commits(self):
|
|||
context = node.ctx
|
||||
|
||||
# explicit rejection of known instance fields
|
||||
self.assertTrue(hasattr(node, 'extra'))
|
||||
self.assertHasAttr(node, 'extra')
|
||||
msg = "Name.__replace__ got an unexpected keyword argument 'extra'."
|
||||
with self.assertRaisesRegex(TypeError, re.escape(msg)):
|
||||
copy.replace(node, extra=1)
|
||||
|
|
@ -3071,7 +3071,7 @@ def test_FunctionDef(self):
|
|||
with self.assertWarnsRegex(DeprecationWarning,
|
||||
r"FunctionDef\.__init__ missing 1 required positional argument: 'name'"):
|
||||
node = ast.FunctionDef(args=args)
|
||||
self.assertFalse(hasattr(node, "name"))
|
||||
self.assertNotHasAttr(node, "name")
|
||||
self.assertEqual(node.decorator_list, [])
|
||||
node = ast.FunctionDef(name='foo', args=args)
|
||||
self.assertEqual(node.name, 'foo')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue