@ -7,6 +7,7 @@
# it under the terms of the GNU General Public License version 2 as
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
# published by the Free Software Foundation.
import sys
import unittest
import unittest
from gallery_dl import extractor , job , config
from gallery_dl import extractor , job , config
@ -14,8 +15,13 @@ from gallery_dl import extractor, job, config
class TestExtractors ( unittest . TestCase ) :
class TestExtractors ( unittest . TestCase ) :
def setUp ( self ) :
def setUp ( self ) :
config . load ( )
name = " gallerydl "
email = " gallerydl@openaliasbox.org "
config . set ( ( " cache " , " file " ) , " :memory: " )
config . set ( ( " cache " , " file " ) , " :memory: " )
config . set ( ( " username " , ) , name )
config . set ( ( " password " , ) , name )
config . set ( ( " extractor " , " nijie " , " username " ) , email )
config . set ( ( " extractor " , " seiga " , " username " ) , email )
def _run_test ( self , extr , url , result ) :
def _run_test ( self , extr , url , result ) :
hjob = job . HashJob ( url , " content " in result )
hjob = job . HashJob ( url , " content " in result )
@ -40,10 +46,19 @@ def _generate_test(extr, tcase):
self . _run_test ( extr , url , result )
self . _run_test ( extr , url , result )
return test
return test
# enable selective testing for direct calls
extractors = extractor . extractors ( )
if __name__ == ' __main__ ' and len ( sys . argv ) > 1 :
print ( sys . argv )
extractors = [
extr for extr in extractors
if extr . category in sys . argv
]
del sys . argv [ 1 : ]
for extr in extractor . extractors ( ) :
skip = ( " exhentai " , " kissmanga " )
# disable extractors that require authentication for now
for extr in extractors :
if hasattr ( extr , " login " ) :
if extr . category in skip :
continue
continue
if hasattr ( extr , " test " ) and extr . test :
if hasattr ( extr , " test " ) and extr . test :
name = " test_ " + extr . __name__ + " _ "
name = " test_ " + extr . __name__ + " _ "