update test/test_extractor.py
This commit is contained in:
@@ -19,6 +19,8 @@ __tests__ = (
|
|||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://35photo.pro/suhoveev",
|
"#url" : "https://35photo.pro/suhoveev",
|
||||||
|
"#comment" : "last photo ID (1267028) isn't given as 'photo-id=\"<id>\" - "
|
||||||
|
"there are only 23 photos without the last one",
|
||||||
"#category": ("", "35photo", "user"),
|
"#category": ("", "35photo", "user"),
|
||||||
"#class" : _35photo._35photoUserExtractor,
|
"#class" : _35photo._35photoUserExtractor,
|
||||||
"#count" : ">= 33",
|
"#count" : ">= 33",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from gallery_dl.extractor import generic
|
|||||||
|
|
||||||
__tests__ = (
|
__tests__ = (
|
||||||
{
|
{
|
||||||
"#url" : "https://www.nongnu.org/lzip/",
|
"#url" : "generic:https://www.nongnu.org/lzip/",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
"#count" : 1,
|
"#count" : 1,
|
||||||
@@ -22,7 +22,7 @@ __tests__ = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://räksmörgås.josefsson.org/",
|
"#url" : "generic:https://räksmörgås.josefsson.org/",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
"#pattern" : "^https://räksmörgås.josefsson.org/",
|
"#pattern" : "^https://räksmörgås.josefsson.org/",
|
||||||
@@ -30,37 +30,37 @@ __tests__ = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://en.wikipedia.org/Main_Page",
|
"#url" : "generic:https://en.wikipedia.org/Main_Page",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://example.org/path/to/file?que=1?&ry=2/#fragment",
|
"#url" : "generic:https://example.org/path/to/file?que=1?&ry=2/#fragment",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://example.org/%27%3C%23/%23%3E%27.htm?key=%3C%26%3E",
|
"#url" : "generic:https://example.org/%27%3C%23/%23%3E%27.htm?key=%3C%26%3E",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://en.wikipedia.org/Main_Page",
|
"#url" : "generic:https://en.wikipedia.org/Main_Page",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://example.org/path/to/file?que=1?&ry=2/#fragment",
|
"#url" : "generic:https://example.org/path/to/file?que=1?&ry=2/#fragment",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://example.org/%27%3C%23/%23%3E%27.htm?key=%3C%26%3E",
|
"#url" : "generic:https://example.org/%27%3C%23/%23%3E%27.htm?key=%3C%26%3E",
|
||||||
"#category": ("", "generic", ""),
|
"#category": ("", "generic", ""),
|
||||||
"#class" : generic.GenericExtractor,
|
"#class" : generic.GenericExtractor,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ __tests__ = (
|
|||||||
{
|
{
|
||||||
"#url" : "https://horne.red/like_my.php",
|
"#url" : "https://horne.red/like_my.php",
|
||||||
"#category": ("Nijie", "horne", "followed"),
|
"#category": ("Nijie", "horne", "followed"),
|
||||||
"#class" : nijie.NijiefollowedExtractor,
|
"#class" : nijie.NijieFollowedExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ __tests__ = (
|
|||||||
{
|
{
|
||||||
"#url" : "https://nijie.info/like_my.php",
|
"#url" : "https://nijie.info/like_my.php",
|
||||||
"#category": ("Nijie", "nijie", "followed"),
|
"#category": ("Nijie", "nijie", "followed"),
|
||||||
"#class" : nijie.NijiefollowedExtractor,
|
"#class" : nijie.NijieFollowedExtractor,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -93,20 +93,24 @@ class TestExtractorModule(unittest.TestCase):
|
|||||||
FakeExtractor.from_url(invalid)
|
FakeExtractor.from_url(invalid)
|
||||||
|
|
||||||
def test_unique_pattern_matches(self):
|
def test_unique_pattern_matches(self):
|
||||||
test_urls = []
|
try:
|
||||||
|
import test.results
|
||||||
|
except ImportError:
|
||||||
|
raise unittest.SkipTest("no test data")
|
||||||
|
|
||||||
# collect testcase URLs
|
# collect testcase URLs
|
||||||
|
test_urls = []
|
||||||
append = test_urls.append
|
append = test_urls.append
|
||||||
for extr in extractor.extractors():
|
|
||||||
for testcase in extr._get_tests():
|
for result in test.results.all():
|
||||||
append((testcase[0], extr))
|
append((result["#url"], result["#class"]))
|
||||||
|
|
||||||
# iterate over all testcase URLs
|
# iterate over all testcase URLs
|
||||||
for url, extr1 in test_urls:
|
for url, extr1 in test_urls:
|
||||||
matches = []
|
matches = []
|
||||||
|
|
||||||
# ... and apply all regex patterns to each one
|
# ... and apply all regex patterns to each one
|
||||||
for extr2 in extractor._cache:
|
for extr2 in _list_classes():
|
||||||
|
|
||||||
# skip DirectlinkExtractor pattern if it isn't tested
|
# skip DirectlinkExtractor pattern if it isn't tested
|
||||||
if extr1 != DirectlinkExtractor and \
|
if extr1 != DirectlinkExtractor and \
|
||||||
@@ -133,15 +137,14 @@ class TestExtractorModule(unittest.TestCase):
|
|||||||
self.assertIs(extr1, matches[0][1], url)
|
self.assertIs(extr1, matches[0][1], url)
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
"""Test for exceptions in Extractor.initialize(()"""
|
"""Test for exceptions in Extractor.initialize() and .finalize()"""
|
||||||
for cls in extractor.extractors():
|
for cls in extractor.extractors():
|
||||||
if cls.category == "ytdl":
|
if cls.category == "ytdl":
|
||||||
continue
|
continue
|
||||||
for test in cls._get_tests():
|
extr = cls.from_url(cls.example)
|
||||||
extr = cls.from_url(test[0])
|
extr.initialize()
|
||||||
extr.initialize()
|
extr.finalize()
|
||||||
extr.finalize()
|
break
|
||||||
break
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.hexversion < 0x3060000, "test fails in CI")
|
@unittest.skipIf(sys.hexversion < 0x3060000, "test fails in CI")
|
||||||
def test_init_ytdl(self):
|
def test_init_ytdl(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user