Skip to content

Commit

Permalink
Make shell tests work on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jnmclarty committed Jun 2, 2016
1 parent 64332d8 commit 2a496c2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions testsuite/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
from testsuite.support import ROOT_DIR, PseudoFile


def safe_line_split(line):
""" parses the path, from message details """

# On certain platforms, the drive notation conflicts
# with the message seperator, inducing problems during tuple unpacking.

split = line.split(':')
if 'win' in sys.platform:
if len(split) == 5:
drive, path, x, y, msg = split
path = drive + ':' + path
elif len(split) == 4:
path, x, y, msg = split
else:
raise Exception("Unhandled edge case parsing message: " + line)
else:
path, x, y, msg = split
return path, x, y, msg


class ShellTestCase(unittest.TestCase):
"""Test the usual CLI options and output."""

Expand Down Expand Up @@ -77,7 +97,7 @@ def test_check_simple(self):
self.assertFalse(stderr)
self.assertEqual(len(stdout), 17)
for line, num, col in zip(stdout, (3, 6, 9, 12), (3, 6, 1, 5)):
path, x, y, msg = line.split(':')
path, x, y, msg = safe_line_split(line)
self.assertTrue(path.endswith(E11))
self.assertEqual(x, str(num))
self.assertEqual(y, str(col))
Expand Down Expand Up @@ -141,7 +161,7 @@ def test_check_diff(self):
self.assertEqual(errcode, 1)
self.assertFalse(stderr)
for line, num, col in zip(stdout, (3, 6), (3, 6)):
path, x, y, msg = line.split(':')
path, x, y, msg = safe_line_split(line)
self.assertEqual(x, str(num))
self.assertEqual(y, str(col))
self.assertTrue(msg.startswith(' E11'))
Expand All @@ -154,7 +174,7 @@ def test_check_diff(self):
self.assertEqual(errcode, 1)
self.assertFalse(stderr)
for line, num, col in zip(stdout, (3, 6), (3, 6)):
path, x, y, msg = line.split(':')
path, x, y, msg = safe_line_split(line)
self.assertEqual(x, str(num))
self.assertEqual(y, str(col))
self.assertTrue(msg.startswith(' E11'))
Expand Down

0 comments on commit 2a496c2

Please sign in to comment.