From 8aca5d4497b97084c6217fd595b94f4e71b32d2c Mon Sep 17 00:00:00 2001 From: jnmclarty Date: Thu, 2 Jun 2016 19:04:30 -0400 Subject: [PATCH] Make shell tests work on windows --- testsuite/test_shell.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py index 760c2284..c9163058 100644 --- a/testsuite/test_shell.py +++ b/testsuite/test_shell.py @@ -7,6 +7,19 @@ from testsuite.support import ROOT_DIR, PseudoFile +def safe_line_split(line): + split = line.split(':') + if 'win' in sys.platform: + try: + drive, path, x, y, msg = split + path = drive + ':' + path + except: + path, x, y, msg = split + else: + path, x, y, msg = split + return path, x, y, msg + + class ShellTestCase(unittest.TestCase): """Test the usual CLI options and output.""" @@ -77,7 +90,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)) @@ -141,7 +154,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')) @@ -154,7 +167,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'))