Skip to content

Commit b19868d

Browse files
cdce8pPierre-Sassoulas
authored andcommitted
Fix failing tests
1 parent da7efb0 commit b19868d

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

tests/test_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ def test_method_locals(self) -> None:
850850
"""Test the 'locals' dictionary of an astroid method."""
851851
method = self.module["YOUPI"]["method"]
852852
# ListComp variables are not accessible outside
853-
self.assertEqual(sorted(method.locals), ["autre", "local", "self"])
853+
self.assertEqual(sorted(method.locals), ["a", "autre", "local", "self"])
854854

855855
def test_unknown_encoding(self) -> None:
856856
with self.assertRaises(AstroidSyntaxError):

tests/test_nodes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,25 @@ def test_module_as_string_pre_3_14(self) -> None:
128128
self.maxDiff = None
129129
module = resources.build_file("data/module.py", "data.module")
130130
with open(resources.find("data/module.py"), encoding="utf-8") as fobj:
131-
self.assertMultiLineEqual(module.as_string(), fobj.read())
131+
# Ignore comments in python file
132+
data_str = "\n".join(
133+
[s for s in fobj.read().split("\n") if not s.lstrip().startswith("# ")]
134+
)
135+
self.assertMultiLineEqual(module.as_string(), data_str)
132136

133137
@pytest.mark.skipif(
134138
not PY314_PLUS, reason="return in finally is now a syntax error"
135139
)
136140
def test_module_as_string(self) -> None:
137141
"""Check as_string on a whole module prepared to be returned identically for py > 3.14."""
142+
self.maxDiff = None
138143
module = resources.build_file("data/module3.14.py", "data.module3.14")
139144
with open(resources.find("data/module3.14.py"), encoding="utf-8") as fobj:
140-
self.assertMultiLineEqual(module.as_string(), fobj.read())
145+
# Ignore comments in python file
146+
data_str = "\n".join(
147+
[s for s in fobj.read().split("\n") if not s.lstrip().startswith("# ")]
148+
)
149+
self.assertMultiLineEqual(module.as_string(), data_str)
141150

142151
def test_module2_as_string(self) -> None:
143152
"""Check as_string on a whole module prepared to be returned identically."""

tests/testdata/python3/data/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def method(self):
5959
return 'hehe'
6060
global_access(local, val=autre)
6161
finally:
62-
# return in finally was previousely tested here but became a syntax error
62+
# return in finally was previously tested here but became a syntax error
6363
# in 3.14 and this file is used in 188/1464 tests
6464
a = local
65-
65+
6666
def static_method():
6767
"""static method test"""
6868
assert MY_DICT, '???'

tests/testdata/python3/data/module3.14.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def method(self):
5959
return 'hehe'
6060
global_access(local, val=autre)
6161
finally:
62-
# return in finally was previousely tested here but became a syntax error
62+
# return in finally was previously tested here but became a syntax error
6363
# in 3.14 and is used in 188/1464 tests
6464
print(local)
65-
65+
6666
def static_method():
6767
"""static method test"""
6868
assert MY_DICT, '???'

0 commit comments

Comments
 (0)