def runCommandLine(self, text): commands = list(lineSplitter(text)) nCommands = len(commands) for i, command in enumerate(commands, start=1): if self.runCommand(command, i, nCommands) is False: return False return True
def testEmptyString(self): """An empty string should result in a list with an empty string.""" self.assertEqual([''], list(lineSplitter('')))
def testEscaped(self): """An escaped | should result in one field, with the escape remvoed.""" self.assertEqual([r'echo hi | wc -c'], list(lineSplitter(r'echo hi \| wc -c')))
def testPlainStrings(self): """An unescaped | should result in the two expected fields.""" self.assertEqual(['hello ', ' there'], list(lineSplitter('hello | there')))
def testString(self): """A string with no | should result in the same string.""" self.assertEqual(['hello'], list(lineSplitter('hello')))