[Bf-blender-cvs] [57646cb] master: Py Tests: manual URL validator

Campbell Barton noreply at git.blender.org
Thu Mar 12 13:49:30 CET 2015


Commit: 57646cb2ce54ef37e37b61754c29ee658052b8cd
Author: Campbell Barton
Date:   Thu Mar 12 20:27:16 2015 +1100
Branches: master
https://developer.blender.org/rB57646cb2ce54ef37e37b61754c29ee658052b8cd

Py Tests: manual URL validator

Support for URL checker to use locally generated manual.

===================================================================

M	tests/python/bl_rna_wiki_reference.py

===================================================================

diff --git a/tests/python/bl_rna_wiki_reference.py b/tests/python/bl_rna_wiki_reference.py
index 5781c53..a637f6d 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)




More information about the Bf-blender-cvs mailing list