diff options
| author | 2019-11-10 22:14:10 -0500 | |
|---|---|---|
| committer | 2019-11-10 22:14:10 -0500 | |
| commit | 3f168e82fc6b60ff8878a7539ad49aa2336025cc (patch) | |
| tree | 08a09e527edf46f238e816aa316144bd7ef5c246 /scripts/create_test_data.py | |
| parent | 82eae732c8dec3e14cfae90fe34987f9a3aa984d (diff) | |
| parent | 0c73e982fa596da07f23b377621ab894a9e64884 (diff) | |
Update upstream source from tag 'upstream/1.11.1'
Update to upstream version '1.11.1'
with Debian dir f73a42d5b98e3bf9f053d0329cbfe78bf5248d2e
Diffstat (limited to 'scripts/create_test_data.py')
| -rwxr-xr-x | scripts/create_test_data.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/scripts/create_test_data.py b/scripts/create_test_data.py deleted file mode 100755 index 14ab0c0..0000000 --- a/scripts/create_test_data.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2015-2019 Mike Fährmann -# -# 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 -# published by the Free Software Foundation. - -"""Create testdata for extractor tests""" - -import argparse - -import util # noqa -from gallery_dl import extractor -from test.test_results import ResultJob, setup_test_config - - -TESTDATA_FMT = """ - test = ("{}", {{ - "url": "{}", - "keyword": "{}", - "content": "{}", - }}) -""" - -TESTDATA_EXCEPTION_FMT = """ - test = ("{}", {{ - "exception": exception.{}, - }}) -""" - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("--content", action="store_true") - parser.add_argument("--recreate", action="store_true") - parser.add_argument("urls", nargs="*") - args = parser.parse_args() - - if args.recreate: - urls = [ - test[0] - for extr in extractor.extractors() if extr.category in args.urls - for test in extr.test - ] - else: - urls = args.urls - - setup_test_config() - - for url in urls: - tjob = ResultJob(url, content=args.content) - try: - tjob.run() - except Exception as exc: - fmt = TESTDATA_EXCEPTION_FMT - data = (exc.__class__.__name__,) - else: - fmt = TESTDATA_FMT - data = (tjob.hash_url.hexdigest(), - tjob.hash_keyword.hexdigest(), - tjob.hash_content.hexdigest()) - print(tjob.extractor.__class__.__name__) - print(fmt.format(url, *data)) - - -if __name__ == '__main__': - main() |
