From 23a64455b1d30b5ed71ac58cb786aeeb54f168c2 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 11 Feb 2014 09:34:59 +0100 Subject: Fix setup.py.RunTests.run() to return proper exit code. The previous situation didn't fail on Travis-CI. But this does, so I had to include also a number of fixes for revealed issues. Fixing #314, #315, #316, and #317 --- test/test_functional.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'test/test_functional.py') diff --git a/test/test_functional.py b/test/test_functional.py index 31fc4ec..44a5c8f 100644 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -18,18 +18,21 @@ ARTICLE_URL = 'https://groups.google.com/d/msg/jbrout' + \ '/xNwoVmC07KI/OfpRHFscUkwJ' -def msg_wo_From(inmsg): - return '\n'.join(inmsg.replace('\r\n', '\n').split('\n')[1:]) - - class TestGGScrapperFunctional(unittest.TestCase): - def setUp(self): - self.dired = lambda x: os.path.join(os.path.dirname(__file__), x) + @staticmethod + def msg_wo_From(inmsg): + if gg_scraper.py3k and isinstance(inmsg, bytes): + inmsg = inmsg.decode() + out = inmsg.replace('\r\n', '\n').split('\n')[1:] + return '\n'.join(out) + + @staticmethod + def dired(x): + return os.path.join(os.path.dirname(__file__), x) def test_collecting_topics(self): page = gg_scraper.Group(IN_URL) topics = page.get_topics() - logging.debug("number of topics = %d", len(topics)) self.assertGreater(len(topics), 0) def test_collecting_articles(self): @@ -39,8 +42,6 @@ class TestGGScrapperFunctional(unittest.TestCase): 'ubuntu 11.04 ?') articles = topic.get_articles() article_count = topic.get_count_articles() - logging.debug('article_count = {0:d}'.format(article_count)) - logging.debug('articles = len {0:d}'.format(len(articles))) self.assertEqual(len(articles), article_count) def test_get_raw_article(self): @@ -49,17 +50,18 @@ class TestGGScrapperFunctional(unittest.TestCase): with io.open(self.dired('message.eml'), 'r', encoding='utf8') as exp_f: - self.assertEqual(msg_wo_From(article.collect_message()), + self.assertEqual(self.msg_wo_From(article.collect_message()), exp_f.read()) def test_py26_unicode_raw_article(self): self.maxDiff = None URL = 'https://groups.google.com/forum/message/raw?' + \ 'msg=django-oscar/BbBiMWwolf0/gn-s0sFYEhkJ' - article = msg_wo_From(gg_scraper.Article(URL).collect_message()) + article = self.msg_wo_From(gg_scraper.Article(URL).collect_message()) with io.open(self.dired('py26_unicode.eml'), 'r', encoding='utf8') as exp_f: - self.assertEqual(article, exp_f.read()) + expected = exp_f.read() + self.assertEqual(article, expected) if __name__ == '__main__': -- cgit