From 36cc4e32f4568d443e2a4e81cd9d101eaa7d3a2f Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sun, 13 Mar 2016 13:03:41 +0100 Subject: [PATCH] Allow selection of comics to test via environment. If you need to run test cases for your new comic module, you can call py.test like this: TESTCOMICS="ComicFury/" py.test -v tests/test_comics.py --- tests/test_comics.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/test_comics.py b/tests/test_comics.py index da4b88d08..0f0d2e0dc 100644 --- a/tests/test_comics.py +++ b/tests/test_comics.py @@ -128,16 +128,21 @@ def get_test_scraperclasses(): # test all comics (this will take some time) scraperclasses = scraper.get_scraperclasses() else: - # Get limited number of scraper tests on Travis builds to make - # it faster - testscrapernames = [ - 'AbstruseGoose', - 'GoComics/CalvinandHobbes', - 'xkcd' - ] + if 'TESTCOMICS' in os.environ: + scraper_pattern = re.compile(os.environ['TESTCOMICS']) + else: + # Get limited number of scraper tests on Travis builds to make it + # faster + testscrapernames = [ + 'AbstruseGoose', + 'GoComics/CalvinandHobbes', + 'xkcd' + ] + scraper_pattern = re.compile('|'.join(testscrapernames)) + scraperclasses = [ scraperclass for scraperclass in scraper.get_scraperclasses() - if scraperclass.getName() in testscrapernames + if scraper_pattern.match(scraperclass.getName()) ] return scraperclasses