Fix random test case.

This commit is contained in:
Bastian Kleineidam 2013-11-08 18:40:55 +01:00
parent bb74005a79
commit 0e780e9741

View file

@ -10,7 +10,6 @@ try:
from urllib.parse import urlsplit from urllib.parse import urlsplit
except ImportError: except ImportError:
from urlparse import urlsplit from urlparse import urlsplit
from itertools import islice
from unittest import TestCase from unittest import TestCase
from dosagelib import scraper from dosagelib import scraper
@ -140,12 +139,17 @@ def make_comic_tester(name, **kwargs):
def generate_comic_testers(): def generate_comic_testers():
"""For each comic scraper, create a test class.""" """For each comic scraper, create a test class."""
g = globals() g = globals()
if "TESTALL" not in os.environ: if "TESTALL" in os.environ:
# Get limited number of scraper tests on Travis builds. # test all comics (this will take some time)
max_scrapers = 1
scraperclasses = islice(scraper.get_scraperclasses(), 0, max_scrapers)
else:
scraperclasses = scraper.get_scraperclasses() scraperclasses = scraper.get_scraperclasses()
else:
# Get limited number of scraper tests on Travis builds to make
# it faster
testscrapernames = ['GoComics/CalvinandHobbes']
scraperclasses = [
scraperclass for scraperclass in scraper.get_scraperclasses()
if scraperclass.getName() in testscrapernames
]
for scraperclass in scraperclasses: for scraperclass in scraperclasses:
name = 'Test'+scraperclass.__name__ name = 'Test'+scraperclass.__name__
g[name] = make_comic_tester(name, scraperclass=scraperclass) g[name] = make_comic_tester(name, scraperclass=scraperclass)