tests/run-tests.py
changeset 52512 c2ee1ad78414
parent 52458 a814534aaedd
child 52513 7fd3a9309d0e
--- a/tests/run-tests.py	Thu Dec 12 10:58:48 2024 +0000
+++ b/tests/run-tests.py	Thu Dec 12 15:00:44 2024 +0000
@@ -97,6 +97,7 @@
     import pygments.formatters as formatters
     import pygments.token as token
     import pygments.style as style
+    from pygments.console import ansiformat
 
     if WINDOWS:
         hgpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -113,8 +114,17 @@
     pygmentspresent = True
     difflexer = lexers.DiffLexer()
     terminal256formatter = formatters.Terminal256Formatter()
+
+    def colorize(text: str, style: str, color: bool = True) -> str:
+        if not color:
+            return text
+        return ansiformat(style, text)
+
 except ImportError:
-    pass
+
+    def colorize(text: str, style: str, color: bool = True) -> str:
+        return text
+
 
 progress_type = {}