diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-03-12 12:27:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-03-12 15:49:15 +0300 |
commit | 57646cb2ce54ef37e37b61754c29ee658052b8cd (patch) | |
tree | ac7d941080783b53beff2976b836552dbe2c4543 /tests/python | |
parent | 4aa51096a7f7c6b0bcc348aa9d683d96c2ff7ffe (diff) |
Py Tests: manual URL validator
Support for URL checker to use locally generated manual.
Diffstat (limited to 'tests/python')
-rw-r--r-- | tests/python/bl_rna_wiki_reference.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/tests/python/bl_rna_wiki_reference.py b/tests/python/bl_rna_wiki_reference.py index 5781c53c045..a637f6d555c 100644 --- a/tests/python/bl_rna_wiki_reference.py +++ b/tests/python/bl_rna_wiki_reference.py @@ -92,13 +92,18 @@ def test_language_coverage(): def test_urls(): + import os import sys import rna_wiki_reference import urllib.error from urllib.request import urlopen - prefix = rna_wiki_reference.url_manual_prefix + # avoid URL lookups if possible + LOCAL_PREFIX = os.environ.get("LOCAL_PREFIX") + if LOCAL_PREFIX is None: + prefix = rna_wiki_reference.url_manual_prefix + urls = {suffix for (rna_id, suffix) in rna_wiki_reference.url_manual_mapping} urls_len = "%d" % len(urls) @@ -113,16 +118,26 @@ def test_urls(): urls_fail = [] - for url in sorted(urls): - url_full = prefix + url - print(" %s ... " % url_full, end="") - sys.stdout.flush() - try: - urlopen(url_full) - print(color_green + "OK" + color_normal) - except urllib.error.HTTPError: - print(color_red + "FAIL!" + color_normal) - urls_fail.append(url) + if LOCAL_PREFIX: + for url in sorted(urls): + url_full = os.path.join(LOCAL_PREFIX, url.partition("#")[0]) + print(" %s ... " % url_full, end="") + if os.path.exists(url_full): + print(color_green + "OK" + color_normal) + else: + print(color_red + "FAIL!" + color_normal) + urls_fail.append(url) + else: + for url in sorted(urls): + url_full = prefix + url + print(" %s ... " % url_full, end="") + sys.stdout.flush() + try: + urlopen(url_full) + print(color_green + "OK" + color_normal) + except urllib.error.HTTPError: + print(color_red + "FAIL!" + color_normal) + urls_fail.append(url) if urls_fail: urls_len = "%d" % len(urls_fail) |