Skip to content

Commit 53e6931

Browse files
committed
check number of lines, now that we're looping
1 parent cac393b commit 53e6931

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Lib/test/test_import/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,9 @@ class substr(str):
999999
""")
10001000
popen = script_helper.spawn_python("main.py", cwd=tmp)
10011001
stdout, stderr = popen.communicate()
1002-
for line in stdout.splitlines():
1002+
lines = stdout.splitlines()
1003+
self.assertEqual(len(lines), 3)
1004+
for line in lines:
10031005
self.assertEqual(line, b"module 'fractions' has no attribute 'Fraction'")
10041006

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

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

10521056
popen = script_helper.spawn_python("main.py", cwd=tmp)
10531057
stdout, stderr = popen.communicate()
1054-
for line in stdout.splitlines():
1058+
lines = stdout.splitlines()
1059+
self.assertEqual(len(lines), 2)
1060+
for line in lines:
10551061
self.assertEqual(line, b"module 'fractions' has no attribute 'Fraction'")
10561062

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

10781086
def test_script_shadowing_stdlib_sys_path_modification(self):

0 commit comments

Comments
 (0)