allow for simplified test data structures
Instead of a strict list of (URL, RESULTS)-tuples, extractor result tests can now be a single (URL, RESULTS)-tuple, if it's just one test, and "only matching" tests can now be a simple string.
This commit is contained in:
@@ -11,7 +11,7 @@ import sys
|
||||
import unittest
|
||||
import string
|
||||
|
||||
import gallery_dl.extractor as extractor
|
||||
from gallery_dl import extractor
|
||||
from gallery_dl.extractor.common import Extractor, Message
|
||||
from gallery_dl.extractor.directlink import DirectlinkExtractor as DLExtractor
|
||||
|
||||
@@ -101,9 +101,7 @@ class TestExtractor(unittest.TestCase):
|
||||
|
||||
# collect testcase URLs
|
||||
for extr in extractor.extractors():
|
||||
if not hasattr(extr, "test"):
|
||||
continue
|
||||
for testcase in extr.test:
|
||||
for testcase in extr._get_tests():
|
||||
test_urls.append((testcase[0], extr))
|
||||
|
||||
# iterate over all testcase URLs
|
||||
|
||||
@@ -182,10 +182,8 @@ def generate_tests():
|
||||
|
||||
# add 'test_...' methods
|
||||
for extr in extractors:
|
||||
if not hasattr(extr, "test") or not extr.test:
|
||||
continue
|
||||
name = "test_" + extr.__name__ + "_"
|
||||
for num, tcase in enumerate(extr.test, 1):
|
||||
for num, tcase in enumerate(extr._get_tests(), 1):
|
||||
test = _generate_test(extr, tcase)
|
||||
test.__name__ = name + str(num)
|
||||
setattr(TestExtractorResults, test.__name__, test)
|
||||
|
||||
Reference in New Issue
Block a user