summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast/test_ast.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-05-22 10:42:50 (GMT)
committerGitHub <noreply@github.com>2025-05-22 10:42:50 (GMT)
commitdb98e0bb127c469842dc119d23e5daacd23862cc (patch)
tree5628e04625c93f2e5bde25aa29dedb3c154a0dec /Lib/test/test_ast/test_ast.py
parentd5f7e80d4407655919b32bbd5746b23af174bc5b (diff)
downloadcpython-db98e0bb127c469842dc119d23e5daacd23862cc.zip
cpython-db98e0bb127c469842dc119d23e5daacd23862cc.tar.gz
cpython-db98e0bb127c469842dc119d23e5daacd23862cc.tar.bz2
[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)
(cherry picked from commit 2602d8ae981c4bae1cada2c174b367d97f712efb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_ast/test_ast.py')
-rw-r--r--Lib/test/test_ast/test_ast.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py
index 0776559..1479a8e 100644
--- a/Lib/test/test_ast/test_ast.py
+++ b/Lib/test/test_ast/test_ast.py
@@ -275,12 +275,12 @@ class AST_Tests(unittest.TestCase):
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 @@ class CopyTests(unittest.TestCase):
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 @@ class CopyTests(unittest.TestCase):
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 @@ class ASTConstructorTests(unittest.TestCase):
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')