def _testMainWithSystemExit(self, cliOptions, expectedExitCode=0): oldLogLevel = _log.level try: arguments = ["scunch.test"] arguments.extend(cliOptions) scunch.main(arguments) self.fail("expected SystemExit with code=%d" % expectedExitCode) # pragma: no cover except SystemExit, error: if expectedExitCode: self.assertEqual(error.code, expectedExitCode)
def _testMain(self, cliOptions, currentFolderPathToSet=None, expectedExitCode=0): logLevelAtStartOfTest = _log.level currentFolderPathAtStartOfTest = os.getcwdu() try: arguments = ["scunch.test"] arguments.extend(cliOptions) if currentFolderPathToSet: os.chdir(currentFolderPathToSet) exitCode, exitError = scunch.main(arguments) if not expectedExitCode and exitError: raise exitError self.assertEqual(exitCode, expectedExitCode) finally: os.chdir(currentFolderPathAtStartOfTest) _log.setLevel(logLevelAtStartOfTest)