Skip to content

Commit 8aca5d4

Browse files
committed
Make shell tests work on windows
1 parent 64332d8 commit 8aca5d4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

testsuite/test_shell.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
from testsuite.support import ROOT_DIR, PseudoFile
88

99

10+
def safe_line_split(line):
11+
split = line.split(':')
12+
if 'win' in sys.platform:
13+
try:
14+
drive, path, x, y, msg = split
15+
path = drive + ':' + path
16+
except:
17+
path, x, y, msg = split
18+
else:
19+
path, x, y, msg = split
20+
return path, x, y, msg
21+
22+
1023
class ShellTestCase(unittest.TestCase):
1124
"""Test the usual CLI options and output."""
1225

@@ -77,7 +90,7 @@ def test_check_simple(self):
7790
self.assertFalse(stderr)
7891
self.assertEqual(len(stdout), 17)
7992
for line, num, col in zip(stdout, (3, 6, 9, 12), (3, 6, 1, 5)):
80-
path, x, y, msg = line.split(':')
93+
path, x, y, msg = safe_line_split(line)
8194
self.assertTrue(path.endswith(E11))
8295
self.assertEqual(x, str(num))
8396
self.assertEqual(y, str(col))
@@ -141,7 +154,7 @@ def test_check_diff(self):
141154
self.assertEqual(errcode, 1)
142155
self.assertFalse(stderr)
143156
for line, num, col in zip(stdout, (3, 6), (3, 6)):
144-
path, x, y, msg = line.split(':')
157+
path, x, y, msg = safe_line_split(line)
145158
self.assertEqual(x, str(num))
146159
self.assertEqual(y, str(col))
147160
self.assertTrue(msg.startswith(' E11'))
@@ -154,7 +167,7 @@ def test_check_diff(self):
154167
self.assertEqual(errcode, 1)
155168
self.assertFalse(stderr)
156169
for line, num, col in zip(stdout, (3, 6), (3, 6)):
157-
path, x, y, msg = line.split(':')
170+
path, x, y, msg = safe_line_split(line)
158171
self.assertEqual(x, str(num))
159172
self.assertEqual(y, str(col))
160173
self.assertTrue(msg.startswith(' E11'))

0 commit comments

Comments
 (0)