--- test_shlex-orig.py 2011-09-03 10:16:44.000000000 -0600 +++ test_shlex.py 2011-11-25 12:01:07.000000000 -0700 @@ -173,6 +173,41 @@ "%s: %s != %s" % (self.data[i][0], l, self.data[i][1:])) + def testSyntaxSplitAmpersand(self): + """Test handling of syntax splitting of &""" + # these should all parse to the same output + src = ['echo hi && echo bye', + 'echo hi&&echo bye', + 'echo "hi"&&echo "bye"'] + ref = ['echo', 'hi', '&&', 'echo', 'bye'] + # Maybe this should be: ['echo', 'hi', '&', '&', 'echo', 'bye'] + for ss in src: + result = shlex.split(ss) + self.assertEqual(ref, result, "While splitting '%s'" % ss) + + def testSyntaxSplitSemicolon(self): + """Test handling of syntax splitting of ;""" + # these should all parse to the same output + src = ['echo hi ; echo bye', + 'echo hi; echo bye', + 'echo hi;echo bye'] + ref = ['echo', 'hi', ';', 'echo', 'bye'] + for ss in src: + result = shlex.split(ss) + self.assertEqual(ref, result, "While splitting '%s'" % ss) + + def testSyntaxSplitRedirect(self): + """Test handling of syntax splitting of >""" + # of course, the same applies to <, | + # these should all parse to the same output + src = ['echo hi > out', + 'echo hi> out', + 'echo hi>out'] + ref = ['echo', 'hi', '>', 'out'] + for ss in src: + result = shlex.split(ss) + self.assertEqual(ref, result, "While splitting '%s'" % ss) + # Allow this test to be used with old shlex.py if not getattr(shlex, "split", None): for methname in dir(ShlexTest):