Skip to content

Commit 82e503f

Browse files
committed
Fix failing tests
1 parent 93064fe commit 82e503f

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
@@ -121,16 +121,25 @@ def test_module_as_string_pre_3_14(self) -> None:
121121
self.maxDiff = None
122122
module = resources.build_file("data/module.py", "data.module")
123123
with open(resources.find("data/module.py"), encoding="utf-8") as fobj:
124-
self.assertMultiLineEqual(module.as_string(), fobj.read())
124+
# Ignore comments in python file
125+
data_str = "\n".join(
126+
[s for s in fobj.read().split("\n") if not s.lstrip().startswith("# ")]
127+
)
128+
self.assertMultiLineEqual(module.as_string(), data_str)
125129

126130
@pytest.mark.skipif(
127131
not PY314_PLUS, reason="return in finally is now a syntax error"
128132
)
129133
def test_module_as_string(self) -> None:
130134
"""Check as_string on a whole module prepared to be returned identically for py > 3.14."""
135+
self.maxDiff = None
131136
module = resources.build_file("data/module3.14.py", "data.module3.14")
132137
with open(resources.find("data/module3.14.py"), encoding="utf-8") as fobj:
133-
self.assertMultiLineEqual(module.as_string(), fobj.read())
138+
# Ignore comments in python file
139+
data_str = "\n".join(
140+
[s for s in fobj.read().split("\n") if not s.lstrip().startswith("# ")]
141+
)
142+
self.assertMultiLineEqual(module.as_string(), data_str)
134143

135144
def test_module2_as_string(self) -> None:
136145
"""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)