changeset 49645:194e654815e6 stable

hghave: refactor checks for pygments versions using checkvers()
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 25 Jan 2023 19:37:06 +0400
parents 5df6d4f06a8f
children c3a76efd0b1c
files tests/hghave.py
diffstat 1 files changed, 9 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Wed Jan 25 19:27:50 2023 +0400
+++ b/tests/hghave.py	Wed Jan 25 19:37:06 2023 +0400
@@ -661,52 +661,22 @@
         return False
 
 
-@check("pygments25", "Pygments version >= 2.5")
-def pygments25():
-    try:
-        import pygments
-
-        v = pygments.__version__
-    except ImportError:
-        return False
-
-    parts = v.split(".")
-    major = int(parts[0])
-    minor = int(parts[1])
-
-    return (major, minor) >= (2, 5)
-
-
-@check("pygments211", "Pygments version >= 2.11")
-def pygments211():
+def getpygmentsversion():
     try:
         import pygments
 
         v = pygments.__version__
+
+        parts = v.split(".")
+        return (int(parts[0]), int(parts[1]))
     except ImportError:
-        return False
-
-    parts = v.split(".")
-    major = int(parts[0])
-    minor = int(parts[1])
-
-    return (major, minor) >= (2, 11)
+        return (0, 0)
 
 
-@check("pygments214", "Pygments version >= 2.14")
-def pygments214():
-    try:
-        import pygments
-
-        v = pygments.__version__
-    except ImportError:
-        return False
-
-    parts = v.split(".")
-    major = int(parts[0])
-    minor = int(parts[1])
-
-    return (major, minor) >= (2, 14)
+@checkvers("pygments", "Pygments version >= %s", (2.5, 2.11, 2.14))
+def has_pygments_range(v):
+    major, minor = v.split('.')[0:2]
+    return getpygmentsversion() >= (int(major), int(minor))
 
 
 @check("outer-repo", "outer repo")