2016-04-16 10:01:43 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-10-28 22:21:41 +00:00
|
|
|
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
2016-04-16 10:01:43 +00:00
|
|
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
2016-04-26 06:03:34 +00:00
|
|
|
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
2016-04-16 10:01:43 +00:00
|
|
|
|
|
|
|
import re
|
|
|
|
import operator
|
|
|
|
import os
|
|
|
|
|
|
|
|
from dosagelib import scraper
|
|
|
|
|
|
|
|
|
|
|
|
def get_test_scrapers():
|
|
|
|
"""Return scrapers that should be tested."""
|
|
|
|
if "TESTALL" in os.environ:
|
|
|
|
# test all comics (this will take some time)
|
|
|
|
scrapers = scraper.get_scrapers()
|
|
|
|
else:
|
|
|
|
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 = [
|
2016-04-26 06:03:34 +00:00
|
|
|
# "classic" _BasicScraper
|
2016-04-16 10:01:43 +00:00
|
|
|
'AbstruseGoose',
|
2016-04-26 06:03:34 +00:00
|
|
|
# complex _ParserScraper
|
2016-04-16 10:01:43 +00:00
|
|
|
'GoComics/CalvinAndHobbes',
|
2016-04-26 06:03:34 +00:00
|
|
|
# _WordPressScraper
|
|
|
|
'GrrlPower'
|
2016-04-16 10:01:43 +00:00
|
|
|
]
|
2016-04-26 06:03:34 +00:00
|
|
|
scraper_pattern = re.compile('^(' + '|'.join(testscrapernames) +
|
|
|
|
')$')
|
2016-04-16 10:01:43 +00:00
|
|
|
|
|
|
|
scrapers = [
|
|
|
|
scraperobj for scraperobj in scraper.get_scrapers()
|
|
|
|
if scraper_pattern.match(scraperobj.name)
|
|
|
|
]
|
|
|
|
return scrapers
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
|
|
if 'scraperobj' in metafunc.fixturenames:
|
|
|
|
metafunc.parametrize('scraperobj', get_test_scrapers(),
|
|
|
|
ids=operator.attrgetter('name'))
|