>>> py3-asttokens: Building community/py3-asttokens 2.0.5-r1 (using abuild 3.10.0_rc1-r2) started Wed, 26 Oct 2022 19:04:39 +0000 >>> py3-asttokens: Checking sanity of /home/buildozer/aports/community/py3-asttokens/APKBUILD... >>> py3-asttokens: Analyzing dependencies... >>> py3-asttokens: Installing for build: build-base python3 py3-six py3-setuptools py3-astroid py3-pytest (1/22) Installing libbz2 (1.0.8-r3) (2/22) Installing libffi (3.4.3-r0) (3/22) Installing gdbm (1.23-r0) (4/22) Installing xz-libs (5.2.7-r0) (5/22) Installing mpdecimal (2.5.1-r1) (6/22) Installing readline (8.2.0-r0) (7/22) Installing sqlite-libs (3.39.4-r0) (8/22) Installing python3 (3.10.8-r3) (9/22) Installing py3-six (1.16.0-r3) (10/22) Installing py3-parsing (3.0.9-r0) (11/22) Installing py3-packaging (21.3-r2) (12/22) Installing py3-setuptools (65.5.0-r0) (13/22) Installing py3-lazy-object-proxy (1.7.1-r0) (14/22) Installing py3-wrapt (1.14.1-r0) (15/22) Installing py3-astroid (2.12.12-r0) (16/22) Installing py3-attrs (22.1.0-r0) (17/22) Installing py3-iniconfig (1.1.1-r3) (18/22) Installing py3-pluggy (1.0.0-r1) (19/22) Installing py3-py (1.11.0-r0) (20/22) Installing py3-tomli (2.0.1-r1) (21/22) Installing py3-pytest (7.1.3-r1) (22/22) Installing .makedepends-py3-asttokens (20221026.190501) Executing busybox-1.35.0-r27.trigger OK: 356 MiB in 114 packages >>> py3-asttokens: Cleaning up srcdir >>> py3-asttokens: Cleaning up pkgdir >>> py3-asttokens: Fetching https://distfiles.alpinelinux.org/distfiles/v3.17/asttokens-2.0.5.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 146 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (22) The requested URL returned error: 404 >>> py3-asttokens: Fetching https://files.pythonhosted.org/packages/source/a/asttokens/asttokens-2.0.5.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 50218 100 50218 0 0 177k 0 --:--:-- --:--:-- --:--:-- 177k >>> py3-asttokens: Fetching https://distfiles.alpinelinux.org/distfiles/v3.17/asttokens-2.0.5.tar.gz >>> py3-asttokens: Checking sha512sums... asttokens-2.0.5.tar.gz: OK >>> py3-asttokens: Unpacking /var/cache/distfiles/v3.17/asttokens-2.0.5.tar.gz... /usr/lib/python3.10/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) running build running build_py creating build creating build/lib creating build/lib/asttokens copying asttokens/version.py -> build/lib/asttokens copying asttokens/util.py -> build/lib/asttokens copying asttokens/mark_tokens.py -> build/lib/asttokens copying asttokens/__init__.py -> build/lib/asttokens copying asttokens/line_numbers.py -> build/lib/asttokens copying asttokens/asttokens.py -> build/lib/asttokens ============================= test session starts ============================== platform linux -- Python 3.10.8, pytest-7.1.3, pluggy-1.0.0 -- /usr/bin/python3 cachedir: .pytest_cache rootdir: /home/buildozer/aports/community/py3-asttokens/src/asttokens-2.0.5, configfile: setup.cfg collecting ... collected 107 items tests/test_astroid.py::TestAstroid::test_adjacent_joined_strings PASSED [ 0%] tests/test_astroid.py::TestAstroid::test_adjacent_strings PASSED [ 1%] tests/test_astroid.py::TestAstroid::test_assert_nodes_equal PASSED [ 2%] tests/test_astroid.py::TestAstroid::test_assignment_expressions FAILED [ 3%] tests/test_astroid.py::TestAstroid::test_async_def FAILED [ 4%] tests/test_astroid.py::TestAstroid::test_async_for_and_with PASSED [ 5%] tests/test_astroid.py::TestAstroid::test_await PASSED [ 6%] tests/test_astroid.py::TestAstroid::test_calling_lambdas PASSED [ 7%] tests/test_astroid.py::TestAstroid::test_complex_numbers PASSED [ 8%] tests/test_astroid.py::TestAstroid::test_complex_slice_and_parens PASSED [ 9%] tests/test_astroid.py::TestAstroid::test_comprehensions PASSED [ 10%] tests/test_astroid.py::TestAstroid::test_conditional_expr PASSED [ 11%] tests/test_astroid.py::TestAstroid::test_decorators FAILED [ 12%] tests/test_astroid.py::TestAstroid::test_deep_recursion SKIPPED (ast...) [ 13%] tests/test_astroid.py::TestAstroid::test_del_dict PASSED [ 14%] tests/test_astroid.py::TestAstroid::test_dict_merge PASSED [ 14%] tests/test_astroid.py::TestAstroid::test_dict_order PASSED [ 15%] tests/test_astroid.py::TestAstroid::test_fixture1 PASSED [ 16%] tests/test_astroid.py::TestAstroid::test_fixture10 FAILED [ 17%] tests/test_astroid.py::TestAstroid::test_fixture11 FAILED [ 18%] tests/test_astroid.py::TestAstroid::test_fixture12 PASSED [ 19%] tests/test_astroid.py::TestAstroid::test_fixture13 FAILED [ 20%] tests/test_astroid.py::TestAstroid::test_fixture2 PASSED [ 21%] tests/test_astroid.py::TestAstroid::test_fixture3 FAILED [ 22%] tests/test_astroid.py::TestAstroid::test_fixture4 FAILED [ 23%] tests/test_astroid.py::TestAstroid::test_fixture5 FAILED [ 24%] tests/test_astroid.py::TestAstroid::test_fixture6 PASSED [ 25%] tests/test_astroid.py::TestAstroid::test_fixture7 FAILED [ 26%] tests/test_astroid.py::TestAstroid::test_fixture8 FAILED [ 27%] tests/test_astroid.py::TestAstroid::test_fixture9 FAILED [ 28%] tests/test_astroid.py::TestAstroid::test_fstrings FAILED [ 28%] tests/test_astroid.py::TestAstroid::test_keyword_arg_only PASSED [ 29%] tests/test_astroid.py::TestAstroid::test_mark_tokens_multiline PASSED [ 30%] tests/test_astroid.py::TestAstroid::test_mark_tokens_simple FAILED [ 31%] tests/test_astroid.py::TestAstroid::test_nonascii PASSED [ 32%] tests/test_astroid.py::TestAstroid::test_one_line_if_elif PASSED [ 33%] tests/test_astroid.py::TestAstroid::test_paren_attr PASSED [ 34%] tests/test_astroid.py::TestAstroid::test_parens_around_func PASSED [ 35%] tests/test_astroid.py::TestAstroid::test_print_function FAILED [ 36%] tests/test_astroid.py::TestAstroid::test_return_annotation PASSED [ 37%] tests/test_astroid.py::TestAstroid::test_slices PASSED [ 38%] tests/test_astroid.py::TestAstroid::test_splat FAILED [ 39%] tests/test_astroid.py::TestAstroid::test_statements_with_semicolons PASSED [ 40%] tests/test_astroid.py::TestAstroid::test_sys_modules FAILED [ 41%] tests/test_astroid.py::TestAstroid::test_trailing_commas PASSED [ 42%] tests/test_astroid.py::TestAstroid::test_tuples FAILED [ 42%] tests/test_astroid.py::TestAstroid::test_with PASSED [ 43%] tests/test_asttokens.py::TestASTTokens::test_coding_declaration PASSED [ 44%] tests/test_asttokens.py::TestASTTokens::test_token_methods PASSED [ 45%] tests/test_asttokens.py::TestASTTokens::test_tokenizing PASSED [ 46%] tests/test_asttokens.py::TestASTTokens::test_unicode_offsets PASSED [ 47%] tests/test_asttokens.py::test_filename PASSED [ 48%] tests/test_asttokens.py::test_doesnt_have_location PASSED [ 49%] tests/test_line_numbers.py::TestLineNumbers::test_line_numbers PASSED [ 50%] tests/test_line_numbers.py::TestLineNumbers::test_unicode PASSED [ 51%] tests/test_line_numbers.py::TestLineNumbers::test_utf8_offsets PASSED [ 52%] tests/test_mark_tokens.py::TestMarkTokens::test_adjacent_joined_strings PASSED [ 53%] tests/test_mark_tokens.py::TestMarkTokens::test_adjacent_strings PASSED [ 54%] tests/test_mark_tokens.py::TestMarkTokens::test_assert_nodes_equal PASSED [ 55%] tests/test_mark_tokens.py::TestMarkTokens::test_assignment_expressions PASSED [ 56%] tests/test_mark_tokens.py::TestMarkTokens::test_async_def PASSED [ 57%] tests/test_mark_tokens.py::TestMarkTokens::test_async_for_and_with PASSED [ 57%] tests/test_mark_tokens.py::TestMarkTokens::test_await PASSED [ 58%] tests/test_mark_tokens.py::TestMarkTokens::test_calling_lambdas PASSED [ 59%] tests/test_mark_tokens.py::TestMarkTokens::test_complex_numbers PASSED [ 60%] tests/test_mark_tokens.py::TestMarkTokens::test_complex_slice_and_parens PASSED [ 61%] tests/test_mark_tokens.py::TestMarkTokens::test_comprehensions PASSED [ 62%] tests/test_mark_tokens.py::TestMarkTokens::test_conditional_expr PASSED [ 63%] tests/test_mark_tokens.py::TestMarkTokens::test_decorators PASSED [ 64%] tests/test_mark_tokens.py::TestMarkTokens::test_deep_recursion PASSED [ 65%] tests/test_mark_tokens.py::TestMarkTokens::test_del_dict PASSED [ 66%] tests/test_mark_tokens.py::TestMarkTokens::test_dict_merge PASSED [ 67%] tests/test_mark_tokens.py::TestMarkTokens::test_dict_order PASSED [ 68%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture1 PASSED [ 69%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture10 PASSED [ 70%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture11 PASSED [ 71%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture12 PASSED [ 71%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture13 PASSED [ 72%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture2 PASSED [ 73%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture3 PASSED [ 74%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture4 PASSED [ 75%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture5 PASSED [ 76%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture6 PASSED [ 77%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture7 PASSED [ 78%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture8 PASSED [ 79%] tests/test_mark_tokens.py::TestMarkTokens::test_fixture9 PASSED [ 80%] tests/test_mark_tokens.py::TestMarkTokens::test_fstrings PASSED [ 81%] tests/test_mark_tokens.py::TestMarkTokens::test_keyword_arg_only PASSED [ 82%] tests/test_mark_tokens.py::TestMarkTokens::test_mark_tokens_multiline PASSED [ 83%] tests/test_mark_tokens.py::TestMarkTokens::test_mark_tokens_simple PASSED [ 84%] tests/test_mark_tokens.py::TestMarkTokens::test_nonascii PASSED [ 85%] tests/test_mark_tokens.py::TestMarkTokens::test_one_line_if_elif PASSED [ 85%] tests/test_mark_tokens.py::TestMarkTokens::test_paren_attr PASSED [ 86%] tests/test_mark_tokens.py::TestMarkTokens::test_parens_around_func PASSED [ 87%] tests/test_mark_tokens.py::TestMarkTokens::test_print_function PASSED [ 88%] tests/test_mark_tokens.py::TestMarkTokens::test_return_annotation PASSED [ 89%] tests/test_mark_tokens.py::TestMarkTokens::test_slices PASSED [ 90%] tests/test_mark_tokens.py::TestMarkTokens::test_splat PASSED [ 91%] tests/test_mark_tokens.py::TestMarkTokens::test_statements_with_semicolons PASSED [ 92%] tests/test_mark_tokens.py::TestMarkTokens::test_sys_modules PASSED [ 93%] tests/test_mark_tokens.py::TestMarkTokens::test_trailing_commas PASSED [ 94%] tests/test_mark_tokens.py::TestMarkTokens::test_tuples PASSED [ 95%] tests/test_mark_tokens.py::TestMarkTokens::test_with PASSED [ 96%] tests/test_util.py::TestUtil::test_replace PASSED [ 97%] tests/test_util.py::TestUtil::test_walk_ast PASSED [ 98%] tests/test_util.py::TestUtil::test_walk_astroid PASSED [ 99%] tests/test_util.py::test_expect_token PASSED [100%] =================================== FAILURES =================================== ___________________ TestAstroid.test_assignment_expressions ____________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=21, col_offset=0, end_lineno=21, end_col_offset=7)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=7)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=21, col_offset=0, end_lineno=21, end_col_offset=7) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=7) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = 21, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 21, second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 21, second = 2, msg = '21 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 21 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_assignment_expressions(self): # From https://www.python.org/dev/peps/pep-0572/ > self.create_mark_checker(""" # Handle a matched regex if (match := pattern.search(data)) is not None: # Do something with match pass # A loop that can't be trivially rewritten using 2-arg iter() while chunk := file.read(8192): process(chunk) # Reuse a value that's expensive to compute [y := f(x), y**2, y**3] # Share a subexpression between a comprehension filter clause and its output filtered_data = [y for x in data if (y := f(x)) is not None] y0 = (y1 := f(x)) # Valid, though discouraged foo(x=(y := f(x))) # Valid, though probably confusing def foo(answer=(p := 42)): # Valid, though not great style ... def foo(answer: (p := 42) = 5): # Valid, but probably never useful ... lambda: (x := 1) # Valid, but unlikely to be useful (x := lambda: 1) # Valid lambda line: (m := re.match(pattern, line)) and m.group(1) # Valid if any((comment := line).startswith('#') for line in lines): print("First comment:", comment) if all((nonblank := line).strip() == '' for line in lines): print("All lines are blank") partial_sums = [total := total + v for v in values] """) tests/test_mark_tokens.py:678: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[43 chars] 21,\n 0,\n 21,\n 7],\n de[699 chars]))])" != "Func[43 chars] 2,\n 0,\n 2,\n 7],\n deco[697 chars]))])" E FunctionDef( E name='foo', E position=[ E - 21, E ? - E + 2, E 0, E - 21, E ? - E + 2, E 7], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='answer')], E defaults=[NamedExpr( E target=Name(name='p'), E value=Const( E value=42, E kind=None))], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Expr(value=Const( E value=Ellipsis, E kind=None))]) __________________________ TestAstroid.test_async_def __________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', ), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] t2 = [('decorators', ), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=6, col_offset=0, end_lineno=6, end_col_offset=13)) t2 = ('position', Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=13)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=6, col_offset=0, end_lineno=6, end_col_offset=13) t2 = Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=13) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 6 t2 = 3 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 3, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 3, msg = '6 != 3' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 6 != 3 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_async_def(self): > self.create_mark_checker(""" async def foo(): pass @decorator async def foo(): pass """) tests/test_mark_tokens.py:646: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Asyn[47 chars] 6,\n 0,\n 6,\n 13],\n de[519 chars]()])" != "Asyn[47 chars] 3,\n 0,\n 3,\n 13],\n de[519 chars]()])" E AsyncFunctionDef( E name='foo', E position=[ E - 6, E ? ^ E + 3, E ? ^ E 0, E - 6, E ? ^ E + 3, E ? ^ E 13], E decorators=Decorators(nodes=[Name(name='decorator')]), E args=Arguments( E vararg=None, E kwarg=None, E args=[], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Pass()]) _________________________ TestAstroid.test_decorators __________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', ), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'g'), ...] t2 = [('decorators', ), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'g'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=6, col_offset=0, end_lineno=6, end_col_offset=5)) t2 = ('position', Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=5)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=6, col_offset=0, end_lineno=6, end_col_offset=5) t2 = Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=5) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 6 t2 = 3 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 3, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 3, msg = '6 != 3' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 6 != 3 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_decorators(self): # See https://bitbucket.org/plas/thonny/issues/49/range-marker-fails-with-decorators source = textwrap.dedent(""" @deco1 def f(): pass @deco2(a=1) def g(x): pass @deco3() def g(x): pass """) > m = self.create_mark_checker(source) tests/test_mark_tokens.py:491: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[40 chars] 6,\n 0,\n 6,\n 5],\n dec[742 chars]()])" != "Func[40 chars] 3,\n 0,\n 3,\n 5],\n dec[742 chars]()])" E FunctionDef( E name='g', E position=[ E - 6, E ? ^ E + 3, E ? ^ E 0, E - 6, E ? ^ E + 3, E ? ^ E 5], E decorators=Decorators(nodes=[Call( E func=Name(name='deco2'), E args=[], E keywords=[Keyword( E arg='a', E value=Const( E value=1, E kind=None))])]), E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='x')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fixture10 __________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ...0>, , ]), ('name', 'TestCase'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ...0>, , ]), ('name', 'TestCase'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('body', [, , , ]) t2 = ('body', [, , , ]) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [, , , ] t2 = [, , , ] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'setUp'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'setUp'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=6, col_offset=4, end_lineno=6, end_col_offset=13)) t2 = ('position', Position(lineno=4, col_offset=4, end_lineno=4, end_col_offset=13)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=6, col_offset=4, end_lineno=6, end_col_offset=13) t2 = Position(lineno=4, col_offset=4, end_lineno=4, end_col_offset=13) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 6 t2 = 4 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 4, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 6 second = 4, msg = '6 != 4' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 6 != 4 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture10(self): self.verify_fixture_file('astroid/noendingnewline.py') tests/test_mark_tokens.py:173: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[68 chars] 4,\n 0,\n 4,\n 14],\n de[5231 chars]])])" != "Clas[68 chars] 2,\n 0,\n 2,\n 14],\n de[5229 chars]])])" E ClassDef( E name='TestCase', E is_dataclass=False, E position=[ E - 4, E ? ^ E + 2, E ? ^ E 0, E - 4, E ? ^ E + 2, E ? ^ E 14], E decorators=None, E bases=[Attribute( E attrname='TestCase', E expr=Name(name='unittest'))], E keywords=[], E doc_node=None, E body=[ E FunctionDef( E name='setUp', E position=[ E - 6, E 4, E - 6, E ? ^ E + 4, E ? ^ E + 4, E 13], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='self')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Expr(value=Call( E func=Attribute( E attrname='setUp', E expr=Attribute( E attrname='TestCase', E expr=Name(name='unittest'))), E args=[Name(name='self')], E keywords=[]))]), E FunctionDef( E name='tearDown', E position=[ E - 10, E ? ^^ E + 8, E ? ^ E 4, E - 10, E ? ^^ E + 8, E ? ^ E 16], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='self')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Expr(value=Call( E func=Attribute( E attrname='tearDown', E expr=Attribute( E attrname='TestCase', E expr=Name(name='unittest'))), E args=[Name(name='self')], E keywords=[]))]), E FunctionDef( E name='testIt', E position=[ E - 13, E ? ^ E + 11, E ? ^ E 4, E - 13, E ? ^ E + 11, E ? ^ E 14], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='self')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Assign( E targets=[Attribute( E attrname='a', E expr=Name(name='self'))], E value=Const( E value=10, E kind=None)), E Expr(value=Call( E func=Attribute( E attrname='xxx', E expr=Name(name='self')), E args=[], E keywords=[]))]), E FunctionDef( E name='xxx', E position=[ E - 18, E ? ^ E + 16, E ? ^ E 4, E - 18, E ? ^ E + 16, E ? ^ E 11], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='self')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[ E If( E test=Const( E value=False, E kind=None), E body=[Pass(), Expr(value=Call( E func=Name(name='print'), E args=[Const( E value='a', E kind=None)], E keywords=[]))], E orelse=[]), E If( E test=Const( E value=False, E kind=None), E body=[Pass(), Pass()], E orelse=[]), E If( E test=Const( E value=False, E kind=None), E body=[Pass(), Expr(value=Call( E func=Name(name='print'), E args=[Const( E value='rara', E kind=None)], E keywords=[]))], E orelse=[])])]) __________________________ TestAstroid.test_fixture11 __________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Aaa'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Aaa'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=9)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=9)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=9) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=9) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 5 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = '5 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 5 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture11(self): self.verify_fixture_file('astroid/notall.py') tests/test_mark_tokens.py:174: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[63 chars] 5,\n 0,\n 5,\n 9],\n dec[78 chars]()])" != "Clas[63 chars] 2,\n 0,\n 2,\n 9],\n dec[78 chars]()])" E ClassDef( E name='Aaa', E is_dataclass=False, E position=[ E - 5, E ? ^ E + 2, E ? ^ E 0, E - 5, E ? ^ E + 2, E ? ^ E 9], E decorators=None, E bases=[], E keywords=[], E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fixture13 __________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'NotImplemented'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'NotImplemented'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=20)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=20)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=20) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=20) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 3 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 3 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 3 second = 2, msg = '3 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 3 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture13(self): self.verify_fixture_file('astroid/suppliermodule_test.py') tests/test_mark_tokens.py:176: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[74 chars] 3,\n 0,\n 3,\n 20],\n de[101 chars]()])" != "Clas[74 chars] 2,\n 0,\n 2,\n 20],\n de[101 chars]()])" E ClassDef( E name='NotImplemented', E is_dataclass=False, E position=[ E - 3, E ? ^ E + 2, E ? ^ E 0, E - 3, E ? ^ E + 2, E ? ^ E 20], E decorators=None, E bases=[Name(name='Exception')], E keywords=[], E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fixture3 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Aaa'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Aaa'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=9)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=9)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=9) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=9) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 5, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = '5 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 5 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture3(self): self.verify_fixture_file('astroid/all.py') tests/test_mark_tokens.py:166: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[63 chars] 5,\n 0,\n 5,\n 9],\n dec[78 chars]()])" != "Clas[63 chars] 2,\n 0,\n 2,\n 9],\n dec[78 chars]()])" E ClassDef( E name='Aaa', E is_dataclass=False, E position=[ E - 5, E ? ^ E + 2, E ? ^ E 0, E - 5, E ? ^ E + 2, E ? ^ E 9], E decorators=None, E bases=[], E keywords=[], E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fixture4 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Toto'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Toto'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=4, col_offset=0, end_lineno=4, end_col_offset=10)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=10)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=4, col_offset=0, end_lineno=4, end_col_offset=10) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=10) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 4, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 4 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 4 second = 2, msg = '4 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 4 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture4(self): self.verify_fixture_file('astroid/clientmodule_test.py') tests/test_mark_tokens.py:167: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[64 chars] 4,\n 0,\n 4,\n 10],\n de[79 chars]()])" != "Clas[64 chars] 2,\n 0,\n 2,\n 10],\n de[79 chars]()])" E ClassDef( E name='Toto', E is_dataclass=False, E position=[ E - 4, E ? ^ E + 2, E ? ^ E 0, E - 4, E ? ^ E + 2, E ? ^ E 10], E decorators=None, E bases=[], E keywords=[], E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fixture5 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', [, ]), ('name', 'Page'), ...] t2 = [('decorators', None), ('bases', []), ('keywords', []), ('doc_node', None), ('body', [, ]), ('name', 'Page'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('body', [, ]) t2 = ('body', [, ]) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [, ] t2 = [, ] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', [<...ign l.9 at 0x7fff9296f460>, , ]), ('name', 'getPage'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', [<...ssign l.7 at 0x7fff92cb2950>, , ]), ('name', 'getPage'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=7, col_offset=4, end_lineno=7, end_col_offset=15)) t2 = ('position', Position(lineno=5, col_offset=4, end_lineno=5, end_col_offset=15)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=7, col_offset=4, end_lineno=7, end_col_offset=15) t2 = Position(lineno=5, col_offset=4, end_lineno=5, end_col_offset=15) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 7, t2 = 5 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 7 second = 5, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 7 second = 5, msg = '7 != 5' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 7 != 5 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture5(self): self.verify_fixture_file('astroid/descriptor_crash.py') tests/test_mark_tokens.py:168: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[64 chars] 4,\n 0,\n 4,\n 10],\n de[1986 chars]])])" != "Clas[64 chars] 2,\n 0,\n 2,\n 10],\n de[1986 chars]])])" E ClassDef( E name='Page', E is_dataclass=False, E position=[ E - 4, E ? ^ E + 2, E ? ^ E 0, E - 4, E ? ^ E + 2, E ? ^ E 10], E decorators=None, E bases=[Name(name='object')], E keywords=[], E doc_node=None, E body=[Assign( E targets=[Name(name='_urlOpen')], E value=Call( E func=Name(name='staticmethod'), E args=[Attribute( E attrname='urlopen', E expr=Name(name='urllib'))], E keywords=[])), E FunctionDef( E name='getPage', E position=[ E - 7, E ? ^ E + 5, E ? ^ E 4, E - 7, E ? ^ E + 5, E ? ^ E 15], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='self'), Name(name='url')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None, None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None, None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[ E Assign( E targets=[Name(name='handle')], E value=Call( E func=Attribute( E attrname='_urlOpen', E expr=Name(name='self')), E args=[Name(name='url')], E keywords=[])), E Assign( E targets=[Name(name='data')], E value=Call( E func=Attribute( E attrname='read', E expr=Name(name='handle')), E args=[], E keywords=[])), E Expr(value=Call( E func=Attribute( E attrname='close', E expr=Name(name='handle')), E args=[], E keywords=[])), E Return(value=Name(name='data'))])]) __________________________ TestAstroid.test_fixture7 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'definition'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'definition'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=15, col_offset=0, end_lineno=15, end_col_offset=14)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=14)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=15, col_offset=0, end_lineno=15, end_col_offset=14) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=14) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 15 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 15 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 15 second = 2, msg = '15 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 15 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture7(self): self.verify_fixture_file('astroid/format.py') tests/test_mark_tokens.py:170: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[49 chars] 15,\n 0,\n 15,\n 14],\n [849 chars]))])" != "Func[49 chars] 2,\n 0,\n 2,\n 14],\n de[847 chars]))])" E FunctionDef( E name='definition', E position=[ E - 15, E ? ^^ E + 2, E ? ^ E 0, E - 15, E ? ^^ E + 2, E ? ^ E 14], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[ E Name(name='a'), E Name(name='b'), E Name(name='c')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[ E None, E None, E None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[ E None, E None, E None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Return(value=BinOp( E op='+', E left=BinOp( E op='+', E left=Name(name='a'), E right=Name(name='b')), E right=Name(name='c')))]) __________________________ TestAstroid.test_fixture8 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', , , ]), ('name', 'global_access'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', , , ]), ('name', 'global_access'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=11, col_offset=0, end_lineno=11, end_col_offset=17)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=17)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=11, col_offset=0, end_lineno=11, end_col_offset=17) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=17) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 11 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 11 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 11 second = 2, msg = '11 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 11 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture8(self): self.verify_fixture_file('astroid/module.py') tests/test_mark_tokens.py:171: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[52 chars] 11,\n 0,\n 11,\n 17],\n [1363 chars]])])" != "Func[52 chars] 2,\n 0,\n 2,\n 17],\n de[1361 chars]])])" E FunctionDef( E name='global_access', E position=[ E - 11, E ? ^^ E + 2, E ? ^ E 0, E - 11, E ? ^^ E + 2, E ? ^ E 17], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='key'), Name(name='val')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None, None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None, None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=Const( E value='function test', E kind=None), E body=[ E Assign( E targets=[Name(name='local')], E value=Const( E value=1, E kind=None)), E Assign( E targets=[Subscript( E ctx=, E value=Name(name='MY_DICT'), E slice=Name(name='key'))], E value=Name(name='val')), E For( E target=Name(name='i'), E iter=Name(name='val'), E body=[If( E test=Name(name='i'), E body=[Delete(targets=[Subscript( E ctx=, E value=Name(name='MY_DICT'), E slice=Name(name='i'))]), E Continue()], E orelse=[Break()])], E orelse=[Return(value=None)])]) __________________________ TestAstroid.test_fixture9 ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('bases', [, ]), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Specialization'), ...] t2 = [('decorators', None), ('bases', [, ]), ('keywords', []), ('doc_node', None), ('body', []), ('name', 'Specialization'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=20)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=20)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=5, col_offset=0, end_lineno=5, end_col_offset=20) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=20) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 5, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 5 second = 2, msg = '5 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 5 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = > def test_fixture9(self): self.verify_fixture_file('astroid/module2.py') tests/test_mark_tokens.py:172: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:134: in verify_fixture_file tested_nodes = m.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Clas[74 chars] 5,\n 0,\n 5,\n 20],\n de[114 chars]()])" != "Clas[74 chars] 2,\n 0,\n 2,\n 20],\n de[114 chars]()])" E ClassDef( E name='Specialization', E is_dataclass=False, E position=[ E - 5, E ? ^ E + 2, E ? ^ E 0, E - 5, E ? ^ E + 2, E ? ^ E 20], E decorators=None, E bases=[Name(name='YOUPI'), Name(name='YO')], E keywords=[], E doc_node=None, E body=[Pass()]) __________________________ TestAstroid.test_fstrings ___________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 't'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 't'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=1, col_offset=0, end_lineno=1, end_col_offset=5)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=5)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=1, col_offset=0, end_lineno=1, end_col_offset=5) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=5) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 1, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 1 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 1 second = 2, msg = '1 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 1 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_fstrings(self): for source in ( '(f"He said his name is {name!r}.",)', "f'{function(kwarg=24)}'", 'a = f"""result: {value:{width}.{precision}}"""', """[f"abc {a['x']} def"]""", "def t():\n return f'{function(kwarg=24)}'"): > self.create_mark_checker(source) tests/test_mark_tokens.py:306: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[40 chars] 1,\n 0,\n 1,\n 5],\n dec[916 chars]))])" != "Func[40 chars] 2,\n 0,\n 2,\n 5],\n dec[916 chars]))])" E FunctionDef( E name='t', E position=[ E - 1, E ? ^ E + 2, E ? ^ E 0, E - 1, E ? ^ E + 2, E ? ^ E 5], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Return(value=JoinedStr(values=[FormattedValue( E conversion=-1, E value=Call( E func=Name(name='function'), E args=[], E keywords=[Keyword( E arg='kwarg', E value=Const( E value=24, E kind=None))]), E format_spec=None)]))]) _____________________ TestAstroid.test_mark_tokens_simple ______________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', , , ]), ('name', 'global_access'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', , , ]), ('name', 'global_access'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=11, col_offset=0, end_lineno=11, end_col_offset=17)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=17)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=11, col_offset=0, end_lineno=11, end_col_offset=17) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=17) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = 11, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 11, second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 11, second = 2, msg = '11 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 11 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_mark_tokens_simple(self): source = tools.read_fixture('astroid', 'module.py') > m = self.create_mark_checker(source) tests/test_mark_tokens.py:73: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[52 chars] 11,\n 0,\n 11,\n 17],\n [1363 chars]])])" != "Func[52 chars] 2,\n 0,\n 2,\n 17],\n de[1361 chars]])])" E FunctionDef( E name='global_access', E position=[ E - 11, E ? ^^ E + 2, E ? ^ E 0, E - 11, E ? ^^ E + 2, E ? ^ E 17], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='key'), Name(name='val')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None, None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None, None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=Const( E value='function test', E kind=None), E body=[ E Assign( E targets=[Name(name='local')], E value=Const( E value=1, E kind=None)), E Assign( E targets=[Subscript( E ctx=, E value=Name(name='MY_DICT'), E slice=Name(name='key'))], E value=Name(name='val')), E For( E target=Name(name='i'), E iter=Name(name='val'), E body=[If( E test=Name(name='i'), E body=[Delete(targets=[Subscript( E ctx=, E value=Name(name='MY_DICT'), E slice=Name(name='i'))]), E Continue()], E orelse=[Break()])], E orelse=[Return(value=None)])]) _______________________ TestAstroid.test_print_function ________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', ), ('body', [, ]), ('name', 'enumerate'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', ), ('body', [, ]), ('name', 'enumerate'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=7, col_offset=4, end_lineno=7, end_col_offset=17)) t2 = ('position', Position(lineno=2, col_offset=4, end_lineno=2, end_col_offset=17)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=7, col_offset=4, end_lineno=7, end_col_offset=17) t2 = Position(lineno=2, col_offset=4, end_lineno=2, end_col_offset=17) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 7 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 7, second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = first = 7, second = 2, msg = '7 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 7 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_print_function(self): # This testcase imports print as function (using from __future__). Check that we can parse it. # verify_all_nodes doesn't work on Python 2 because the print() call parsed in isolation # is viewed as a Print node since it doesn't see the future import source = tools.read_fixture('astroid/nonregr.py') > m = self.create_mark_checker(source, verify=six.PY3) tests/test_mark_tokens.py:269: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[48 chars] 7,\n 4,\n 7,\n 17],\n de[1139 chars]])])" != "Func[48 chars] 2,\n 4,\n 2,\n 17],\n de[1139 chars]])])" E FunctionDef( E name='enumerate', E position=[ E - 7, E ? ^ E + 2, E ? ^ E 4, E - 7, E ? ^ E + 2, E ? ^ E 17], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='iterable')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=Const( E value='emulates the python2.3 enumerate() function', E kind=None), E body=[Assign( E targets=[Name(name='i')], E value=Const( E value=0, E kind=None)), E For( E target=Name(name='val'), E iter=Name(name='iterable'), E body=[Expr(value=Yield(value=Tuple( E ctx=, E elts=[Name(name='i'), Name(name='val')]))), E AugAssign( E op='+=', E target=Name(name='i'), E value=Const( E value=1, E kind=None))], E orelse=[])]) ____________________________ TestAstroid.test_splat ____________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'print_all'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'print_all'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=13)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=13)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=3, col_offset=0, end_lineno=3, end_col_offset=13) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=13) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 3, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 3 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 3 second = 2, msg = '3 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 3 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_splat(self): # See https://bitbucket.org/plas/thonny/issues/151/debugger-crashes-when-encountering-a-splat source = textwrap.dedent(""" arr = [1,2,3,4,5] def print_all(a, b, c, d, e): print(a, b, c, d ,e) print_all(*arr) """) > m = self.create_mark_checker(source) tests/test_mark_tokens.py:334: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[48 chars] 3,\n 0,\n 3,\n 13],\n de[1024 chars]))])" != "Func[48 chars] 2,\n 0,\n 2,\n 13],\n de[1024 chars]))])" E FunctionDef( E name='print_all', E position=[ E - 3, E ? ^ E + 2, E ? ^ E 0, E - 3, E ? ^ E + 2, E ? ^ E 13], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[ E Name(name='a'), E Name(name='b'), E Name(name='c'), E Name(name='d'), E Name(name='e')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[ E None, E None, E None, E None, E None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[ E None, E None, E None, E None, E None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Expr(value=Call( E func=Name(name='print'), E args=[ E Name(name='a'), E Name(name='b'), E Name(name='c'), E Name(name='d'), E Name(name='e')], E keywords=[]))]) _________________________ TestAstroid.test_sys_modules _________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', '_object_name'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', '_object_name'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=23, col_offset=0, end_lineno=23, end_col_offset=16)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=16)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=23, col_offset=0, end_lineno=23, end_col_offset=16) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=16) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 23 t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 23 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 23 second = 2, msg = '23 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 23 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_sys_modules(self): """ Verify all nodes on source files obtained from sys.modules. This can take a long time as there are many modules, so it only tests all modules if the environment variable ASTTOKENS_SLOW_TESTS has been set. """ modules = list(sys.modules.values()) if not os.environ.get('ASTTOKENS_SLOW_TESTS'): modules = modules[:20] start = time() for module in modules: # Don't let this test (which runs twice) take longer than 13 minutes # to avoid the travis build time limit of 30 minutes if time() - start > 13 * 60: break try: filename = inspect.getsourcefile(module) except TypeError: continue if not filename: continue filename = os.path.abspath(filename) print(filename) try: with io.open(filename) as f: source = f.read() except OSError: continue # Astroid fails with a syntax error if a type comment is on its own line if self.is_astroid_test and re.search(r'^\s*# type: ', source, re.MULTILINE): print('Skipping', filename) continue > self.create_mark_checker(source) tests/test_mark_tokens.py:639: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[52 chars] 23,\n 0,\n 23,\n 16],\n d[1056 chars]])])" != "Func[52 chars] 2,\n 0,\n 2,\n 16],\n dec[1054 chars]])])" E FunctionDef( E name='_object_name', E position=[ E - 23, E ? - E + 2, E 0, E - 23, E ? - E + 2, E 16], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='obj')], E defaults=[], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[TryExcept( E body=[Return(value=Attribute( E attrname='__qualname__', E expr=Name(name='obj')))], E handlers=[ExceptHandler( E type=Name(name='AttributeError'), E name=None, E body=[Return(value=Attribute( E attrname='__qualname__', E expr=Call( E func=Name(name='type'), E args=[Name(name='obj')], E keywords=[])))])], E orelse=[])]) ----------------------------- Captured stdout call ----------------------------- /usr/lib/python3.10/importlib/_bootstrap.py ___________________________ TestAstroid.test_tuples ____________________________ self = test_case = def verify_all_nodes(self, test_case): """ Generically test atok.get_text() on the ast tree: for each statement and expression in the tree, we extract the text, parse it, and see if it produces an equivalent tree. Returns the number of nodes that were tested this way. """ test_case.longMessage = True tested_nodes = 0 for node in self.all_nodes: if not ( util.is_stmt(node) or util.is_expr(node) or util.is_module(node) # In 3.9+, slices are now expressions in the AST, but of course their source code # can't be parsed ) or util.is_slice(node): continue text = self.atok.get_text(node) # await is not allowed outside async functions below 3.7 # parsing again would give a syntax error if 'await' in text and 'async def' not in text and sys.version_info < (3, 7): continue # `elif:` is really just `else: if:` to the AST, # so get_text can return text starting with elif when given an If node. # This is generally harmless and there's probably no good alternative, # but in isolation it's invalid syntax text = re.sub(r'^(\s*)elif(\W)', r'\1if\2', text, re.MULTILINE) rebuilt_node = test_case.parse_snippet(text, node) try: > test_case.assert_nodes_equal(node, rebuilt_node) tests/tools.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = t2 = def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): > self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) tests/test_mark_tokens.py:790: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] t2 = [('decorators', None), ('args', ), ('returns', None), ('doc_node', None), ('body', []), ('name', 'foo'), ...] def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = ('position', Position(lineno=1, col_offset=0, end_lineno=1, end_col_offset=7)) t2 = ('position', Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=7)) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = t1 = Position(lineno=1, col_offset=0, end_lineno=1, end_col_offset=7) t2 = Position(lineno=2, col_offset=0, end_lineno=2, end_col_offset=7) def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): > self.assert_nodes_equal(vc1, vc2) tests/test_mark_tokens.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , t1 = 1, t2 = 2 def assert_nodes_equal(self, t1, t2): # Ignore the context of each node which can change when parsing # substrings of source code. We just want equal structure and contents. for context_classes_group in self.context_classes: if isinstance(t1, context_classes_group): self.assertIsInstance(t2, context_classes_group) break else: self.assertEqual(type(t1), type(t2)) if isinstance(t1, (list, tuple)): self.assertEqual(len(t1), len(t2)) for vc1, vc2 in zip(t1, t2): self.assert_nodes_equal(vc1, vc2) elif isinstance(t1, self.nodes_classes): self.assert_nodes_equal( list(self.iter_fields(t1)), list(self.iter_fields(t2)), ) else: # Weird bug in astroid that collapses spaces in docstrings sometimes maybe if self.is_astroid_test and isinstance(t1, six.string_types): t1 = re.sub(r'^ +$', '', t1, flags=re.MULTILINE) t2 = re.sub(r'^ +$', '', t2, flags=re.MULTILINE) > self.assertEqual(t1, t2) tests/test_mark_tokens.py:800: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 1 second = 2, msg = None def assertEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '==' operator. """ assertion_func = self._getAssertEqualityFunc(first, second) > assertion_func(first, second, msg=msg) /usr/lib/python3.10/unittest/case.py:845: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , first = 1 second = 2, msg = '1 != 2' def _baseAssertEqual(self, first, second, msg=None): """The default assertEqual implementation, not type specific.""" if not first == second: standardMsg = '%s != %s' % _common_shorten_repr(first, second) msg = self._formatMessage(msg, standardMsg) > raise self.failureException(msg) E AssertionError: 1 != 2 /usr/lib/python3.10/unittest/case.py:838: AssertionError During handling of the above exception, another exception occurred: self = def test_tuples(self): def get_tuples(code): m = self.create_mark_checker(code) return [m.atok.get_text(n) for n in m.all_nodes if n.__class__.__name__ == "Tuple"] self.assertEqual(get_tuples("a,"), ["a,"]) self.assertEqual(get_tuples("(a,)"), ["(a,)"]) self.assertEqual(get_tuples("(a),"), ["(a),"]) self.assertEqual(get_tuples("((a),)"), ["((a),)"]) self.assertEqual(get_tuples("(a,),"), ["(a,),", "(a,)"]) self.assertEqual(get_tuples("((a,),)"), ["((a,),)", "(a,)"]) self.assertEqual(get_tuples("()"), ["()"]) self.assertEqual(get_tuples("(),"), ["(),", "()"]) self.assertEqual(get_tuples("((),)"), ["((),)", "()"]) self.assertEqual(get_tuples("((),(a,))"), ["((),(a,))", "()", "(a,)"]) self.assertEqual(get_tuples("((),(a,),)"), ["((),(a,),)", "()", "(a,)"]) self.assertEqual(get_tuples("((),(a,),),"), ["((),(a,),),", "((),(a,),)", "()", "(a,)"]) self.assertEqual(get_tuples('((foo, bar),)'), ['((foo, bar),)', '(foo, bar)']) self.assertEqual(get_tuples('(foo, bar),'), ['(foo, bar),', '(foo, bar)']) > self.assertEqual(get_tuples('def foo(a=()): ((x, (y,)),) = ((), (a,),),'), [ '()', '((x, (y,)),)', '(x, (y,))', '(y,)', '((), (a,),),', '((), (a,),)', '()', '(a,)']) tests/test_mark_tokens.py:416: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_mark_tokens.py:399: in get_tuples m = self.create_mark_checker(code) tests/test_mark_tokens.py:43: in create_mark_checker checker.verify_all_nodes(self) tests/tools.py:103: in verify_all_nodes test_case.assertEqual( E AssertionError: "Func[42 chars] 1,\n 0,\n 1,\n 7],\n dec[1237 chars]))])" != "Func[42 chars] 2,\n 0,\n 2,\n 7],\n dec[1237 chars]))])" E FunctionDef( E name='foo', E position=[ E - 1, E ? ^ E + 2, E ? ^ E 0, E - 1, E ? ^ E + 2, E ? ^ E 7], E decorators=None, E args=Arguments( E vararg=None, E kwarg=None, E args=[Name(name='a')], E defaults=[Tuple( E ctx=, E elts=[])], E kwonlyargs=[], E posonlyargs=[], E posonlyargs_annotations=[], E kw_defaults=[], E annotations=[None], E varargannotation=None, E kwargannotation=None, E kwonlyargs_annotations=[], E type_comment_args=[None], E type_comment_kwonlyargs=[], E type_comment_posonlyargs=[]), E returns=None, E doc_node=None, E body=[Assign( E targets=[Tuple( E ctx=, E elts=[Tuple( E ctx=, E elts=[Name(name='x'), Tuple( E ctx=, E elts=[Name(name='y')])])])], E value=Tuple( E ctx=, E elts=[Tuple( E ctx=, E elts=[Tuple( E ctx=, E elts=[]), E Tuple( E ctx=, E elts=[Name(name='a')])])]))]) =========================== short test summary info ============================ FAILED tests/test_astroid.py::TestAstroid::test_assignment_expressions - Asse... FAILED tests/test_astroid.py::TestAstroid::test_async_def - AssertionError: "... FAILED tests/test_astroid.py::TestAstroid::test_decorators - AssertionError: ... FAILED tests/test_astroid.py::TestAstroid::test_fixture10 - AssertionError: "... FAILED tests/test_astroid.py::TestAstroid::test_fixture11 - AssertionError: "... FAILED tests/test_astroid.py::TestAstroid::test_fixture13 - AssertionError: "... FAILED tests/test_astroid.py::TestAstroid::test_fixture3 - AssertionError: "C... FAILED tests/test_astroid.py::TestAstroid::test_fixture4 - AssertionError: "C... FAILED tests/test_astroid.py::TestAstroid::test_fixture5 - AssertionError: "C... FAILED tests/test_astroid.py::TestAstroid::test_fixture7 - AssertionError: "F... FAILED tests/test_astroid.py::TestAstroid::test_fixture8 - AssertionError: "F... FAILED tests/test_astroid.py::TestAstroid::test_fixture9 - AssertionError: "C... FAILED tests/test_astroid.py::TestAstroid::test_fstrings - AssertionError: "F... FAILED tests/test_astroid.py::TestAstroid::test_mark_tokens_simple - Assertio... FAILED tests/test_astroid.py::TestAstroid::test_print_function - AssertionErr... FAILED tests/test_astroid.py::TestAstroid::test_splat - AssertionError: "Func... FAILED tests/test_astroid.py::TestAstroid::test_sys_modules - AssertionError:... FAILED tests/test_astroid.py::TestAstroid::test_tuples - AssertionError: "Fun... =========== 18 failed, 88 passed, 1 skipped, 571 warnings in 25.85s ============ >>> ERROR: py3-asttokens: check failed >>> py3-asttokens: Uninstalling dependencies... (1/22) Purging .makedepends-py3-asttokens (20221026.190501) (2/22) Purging py3-six (1.16.0-r3) (3/22) Purging py3-setuptools (65.5.0-r0) (4/22) Purging py3-astroid (2.12.12-r0) (5/22) Purging py3-lazy-object-proxy (1.7.1-r0) (6/22) Purging py3-wrapt (1.14.1-r0) (7/22) Purging py3-pytest (7.1.3-r1) (8/22) Purging py3-attrs (22.1.0-r0) (9/22) Purging py3-iniconfig (1.1.1-r3) (10/22) Purging py3-packaging (21.3-r2) (11/22) Purging py3-parsing (3.0.9-r0) (12/22) Purging py3-pluggy (1.0.0-r1) (13/22) Purging py3-py (1.11.0-r0) (14/22) Purging py3-tomli (2.0.1-r1) (15/22) Purging python3 (3.10.8-r3) (16/22) Purging libbz2 (1.0.8-r3) (17/22) Purging libffi (3.4.3-r0) (18/22) Purging gdbm (1.23-r0) (19/22) Purging xz-libs (5.2.7-r0) (20/22) Purging mpdecimal (2.5.1-r1) (21/22) Purging readline (8.2.0-r0) (22/22) Purging sqlite-libs (3.39.4-r0) Executing busybox-1.35.0-r27.trigger OK: 288 MiB in 92 packages