def testCanRunConsoleCommand(self): scunch.run(['svn', '--version']) lines = scunch.run(['svn', '--version'], True) self.assertTrue(lines) firstLine = lines[0] self.assertTrue(firstLine.startswith('svn'), 'first line must start with \'svn\' but is: %r' % firstLine) scunch.run(['svn', '--version'], False, os.curdir)
def testFailsOnUnknownConsoleCommand(self): try: scunch.run(['no_such_command']) self.fail('broken command must cause ScmError') except scunch.ScmError, error: actualErrorMessage = str(error) expectedErrorMessagePattern = 'cannot perform shell command \'no_such_command\': ?Errno *. Command: no_such_command' self.assertTrue(fnmatch.fnmatch(actualErrorMessage, expectedErrorMessagePattern), 'error message must match pattern %r but is: %r' % (expectedErrorMessagePattern, actualErrorMessage))
def testRunWithUmlautEchoResult(self): scunch._setUpEncoding() hello = u'h\xe4ll\xf6' helloWithUmlauts = scunch.run([u'echo', hello], returnStdout=True) normalizedHelloPy = [unicodedata.normalize(scunch._consoleNormalization, hello)] self.assertEqual(helloWithUmlauts, normalizedHelloPy)
def testRunWithUmlautEcho(self): scunch._setUpEncoding() scunch.run([u"echo", u'h\xe4ll\xf6'])
def testRunWithAsciiEcho(self): scunch._setUpEncoding() scunch.run([u"echo", u"hello"])
def testFailsOnBrokenConsoleCommand(self): try: scunch.run(['svn', '--no_such_option']) self.fail('broken command must cause ScmError') except scunch.ScmError, error: self.assertEqual('cannot perform shell command \'svn\'. Error: svn: invalid option: --no_such_option. Command: svn --no_such_option', str(error))