def test_unicode_answer(self): try: assert self.call_howdoi('make a log scale d3') assert self.call_howdoi('python unittest -n3') assert self.call_howdoi('parse html regex -a') assert self.call_howdoi('delete remote git branch -a') except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_multiple_answers(self): try: query = self.queries[0] first_answer = self.call_howdoi(query) second_answer = self.call_howdoi(query + ' -n3') self.assertNotEqual(first_answer, second_answer) except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_position(self): try: query = self.queries[0] first_answer = self.call_howdoi(query) not_first_answer = self.call_howdoi(query + ' -p5') self.assertNotEqual(first_answer, not_first_answer) except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_answer_links_using_l_option(self): try: for query in self.queries: response = self.call_howdoi(query + ' -l') self.assertNotEqual( re.match('http.?://.*questions/\d.*', response, re.DOTALL), None) except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_colorize(self): try: query = self.queries[0] normal = self.call_howdoi(query) colorized = self.call_howdoi('-c ' + query) self.assertTrue(normal.find('[39;') is -1) self.assertTrue(colorized.find('[39;') is not -1) except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_all_text(self): query = self.queries[0] try: first_answer = self.call_howdoi(query) second_answer = self.call_howdoi(query + ' -a') self.assertNotEqual(first_answer, second_answer) self.assertNotEqual( re.match('.*Answer from http.?://.*', second_answer, re.DOTALL), None) except howdoi.BlockError as e: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)
def test_answers(self): try: for query in self.queries: self.assertTrue(self.call_howdoi(query)) for query in self.bad_queries: self.assertTrue(self.call_howdoi(query)) os.environ['HOWDOI_URL'] = 'pt.stackoverflow.com' for query in self.pt_queries: self.assertTrue(self.call_howdoi(query)) except howdoi.BlockError: howdoi._print_err(HowdoiTestCase.BLOCKED_MESSAGE_EXCEPTION)