def test_print(self): searchcmd.stdout = searchcmd.get_print_func(sys.stdout) def mock_search(query_string=None, cmd=None, **kwargs): coms = Commands() cmd = u'git commit \u2013amend -m \u2018new message\u2019' doc = HtmlDocument(u'http://example.com', b'', 1) coms.add_command(Command(cmd, 1, 1, doc)) return coms orig_search = searchcmd.search searchcmd.search = mock_search try: main(['git commit', '--no-cache']) finally: searchcmd.search = orig_search
def test_search_engine_error(self): searchcmd.stdout = searchcmd.get_print_func(sys.stdout) searchcmd.stderr = searchcmd.get_print_func(sys.stderr) with requests_mock.mock() as m: exit_code = main(['find', '--no-cache']) self.assertNotEqual(exit_code, 0)
def tearDown(self): searchcmd.stdout = searchcmd.get_print_func(sys.stdout) searchcmd.stderr = searchcmd.get_print_func(sys.stderr)
def setUp(self): self.internal_stdout = StringIO() self.internal_stderr = StringIO() searchcmd.stdout = searchcmd.get_print_func(self.internal_stdout) searchcmd.stderr = searchcmd.get_print_func(self.internal_stderr)