Skip to content

Commit

Permalink
check number of lines, now that we're looping
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Sep 11, 2024
1 parent cac393b commit 53e6931
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ class substr(str):
""")
popen = script_helper.spawn_python("main.py", cwd=tmp)
stdout, stderr = popen.communicate()
for line in stdout.splitlines():
lines = stdout.splitlines()
self.assertEqual(len(lines), 3)
for line in lines:
self.assertEqual(line, b"module 'fractions' has no attribute 'Fraction'")

with open(os.path.join(tmp, "main.py"), "w", encoding='utf-8') as f:
Expand Down Expand Up @@ -1028,7 +1030,9 @@ class substr(str):
""")
popen = script_helper.spawn_python("main.py", cwd=tmp)
stdout, stderr = popen.communicate()
for line in stdout.splitlines():
lines = stdout.splitlines()
self.assertEqual(len(lines), 3)
for line in lines:
self.assertRegex(line, rb"cannot import name 'Fraction' from 'fractions' \(.*\)")

# Various issues with origin
Expand All @@ -1051,7 +1055,9 @@ class substr(str):

popen = script_helper.spawn_python("main.py", cwd=tmp)
stdout, stderr = popen.communicate()
for line in stdout.splitlines():
lines = stdout.splitlines()
self.assertEqual(len(lines), 2)
for line in lines:
self.assertEqual(line, b"module 'fractions' has no attribute 'Fraction'")

with open(os.path.join(tmp, "main.py"), "w", encoding='utf-8') as f:
Expand All @@ -1072,7 +1078,9 @@ class substr(str):
""")
popen = script_helper.spawn_python("main.py", cwd=tmp)
stdout, stderr = popen.communicate()
for line in stdout.splitlines():
lines = stdout.splitlines()
self.assertEqual(len(lines), 2)
for line in lines:
self.assertRegex(line, rb"cannot import name 'Fraction' from 'fractions' \(.*\)")

def test_script_shadowing_stdlib_sys_path_modification(self):
Expand Down

0 comments on commit 53e6931

Please sign in to comment.