update and improve create_test_data.py script

This commit is contained in:
Mike Fährmann 2019-02-20 15:48:31 +01:00
parent f6734142ee
commit ee2ad76620
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015 Mike Fährmann # Copyright 2015-2019 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# 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
@ -9,21 +9,29 @@
"""Create testdata for extractor tests""" """Create testdata for extractor tests"""
import sys
import os.path
import argparse import argparse
from gallery_dl import job, config, extractor
ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.realpath(ROOTDIR))
from gallery_dl import extractor
from test.test_results import ResultJob, setup_test_config
TESTDATA_FMT = """ TESTDATA_FMT = """
test = [("{}", {{ test = ("{}", {{
"url": "{}", "url": "{}",
"keyword": "{}", "keyword": "{}",
"content": "{}", "content": "{}",
}})] }})
""" """
TESTDATA_EXCEPTION_FMT = """ TESTDATA_EXCEPTION_FMT = """
test = [("{}", {{ test = ("{}", {{
"exception": exception.{}, "exception": exception.{},
}})] }})
""" """
@ -43,10 +51,10 @@ def main():
else: else:
urls = args.urls urls = args.urls
config.load() setup_test_config()
config.set(("downloader", "part"), False)
for url in urls: for url in urls:
tjob = job.TestJob(url, content=args.content) tjob = ResultJob(url, content=args.content)
try: try:
tjob.run() tjob.run()
except Exception as exc: except Exception as exc: