8.2.34 | Linux | www-data (uid:33)
👁 View: ast_helper.py
📁 //snap/core24/2124/usr/lib/python3.12/test/support/ast_helper.py
import ast class ASTTestMixin: """Test mixing to have basic assertions for AST nodes.""" def assertASTEqual(self, ast1, ast2): # Ensure the comparisons start at an AST node self.assertIsInstance(ast1, ast.AST) self.assertIsInstance(ast2, ast.AST) # An AST comparison routine modeled after ast.dump(), but # instead of string building, it traverses the two trees # in lock-step. def traverse_compare(a, b, missing=object()): if type(a) is not type(b): self.fail(f"{type(a)!r} is not {type(b)!r}") if isinstance(a, ast.AST): for field in a._fields: value1 = getattr(a, field, missing) value2 = getattr(b, field, missing) # Singletons are equal by definition, so further # testing can be skipped. if value1 is not value2: traverse_compare(value1, value2) elif isinstance(a, list): try: for node1, node2 in zip(a, b, strict=True): traverse_compare(node1, node2) except ValueError: # Attempt a "pretty" error ala assertSequenceEqual() len1 = len(a) len2 = len(b) if len1 > len2: what = "First" diff = len1 - len2 else: what = "Second" diff = len2 - len1 msg = f"{what} list contains {diff} additional elements." raise self.failureException(msg) from None elif a != b: self.fail(f"{a!r} != {b!r}") traverse_compare(ast1, ast2)
← Back
💻 Terminal
📤 Upload
📂
Click or Drag & Drop
📁 //snap/core24/2124/usr/lib/python3.12/test/support
NameSizePermModifiedActions
📁 __pycache__/-07552026-08-24 03:28🗑 Delete
📁 _hypothesis_stubs/-07552026-08-24 03:28🗑 Delete
__init__.py79.3K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
ast_helper.py1.8K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
asynchat.py11.3K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
asyncore.py19.9K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
bytecode_helper.py4.9K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
hashlib_helper.py1.9K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
hypothesis_helper.py1.4K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
import_helper.py10.5K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
interpreters.py5.7K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
logging_helper.py916B06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
os_helper.py23.7K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
pty_helper.py3K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
script_helper.py11.4K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
smtpd.py30K07552026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
socket_helper.py13.5K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
testcase.py1K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
threading_helper.py7.9K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
warnings_helper.py6.7K06442026-06-19 12:46👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del