def test_returns_execute_result(self): self.stub__find_command(lambda x: 1) self.assertEqual(1, cli.run_argv(["lmirror", "foo"], "in", "out", "err"))
def test_returns_0_when_None_returned_from_execute(self): self.stub__find_command(lambda x: None) self.assertEqual(0, cli.run_argv(["lmirror", "foo"], "in", "out", "err"))
def test_runs_cmd_with_CLI_UI(self): self.stub__find_command(self.capture_ui) cli.run_argv(["lmirror", "--version", "foo"], "in", "out", "err") self.assertEqual(["foo"], self.calls) self.assertIsInstance(self.ui, cli.UI)
def test_no_cmd_issues_help(self): self.stub__find_command(lambda x: 0) cli.run_argv(["lmirror", "--version"], "in", "out", "err") self.assertEqual(["help"], self.calls)
def test_looks_up_cmd_skips_options(self): self.stub__find_command(lambda x: 0) cli.run_argv(["lmirror", "--version", "foo"], "in", "out", "err") self.assertEqual(["foo"], self.calls)
def main(*args, **kwargs): sys.exit(run_argv(sys.argv, sys.stdin, sys.stdout, sys.stderr))