# HG changeset patch # User Gregory Szorc # Date 2020-01-18 18:21:45 # Node ID 5b38c2ab6ad337eca49ba92eefb3da72507f2a59 # Parent f81c17ec303c320a1550b88246466695a6983619 tests: conditionalize test-hightlight.t on pygments version Output changed slightly in pygments 2.5. I thought it was easier to copy the line and add a version check than to add a regular expression because the line has some special characters. I also like tests explicitly calling out where they vary. Differential Revision: https://phab.mercurial-scm.org/D7943 diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -577,6 +577,22 @@ def has_pygments(): 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("outer-repo", "outer repo") def has_outer_repo(): # failing for other reasons than 'no repo' imply that there is a repo diff --git a/tests/test-highlight.t b/tests/test-highlight.t --- a/tests/test-highlight.t +++ b/tests/test-highlight.t @@ -184,7 +184,8 @@ hgweb filerevision, html except (ValueError, IndexError): n = 10 p = primes() - print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) + print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) (pygments25 !) + print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) (no-pygments25 !) @@ -845,7 +846,8 @@ hgweb fileannotate, html changeset - 31 print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) + 31 print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) (pygments25 !) + 31 print("The first %d primes: %s" % (n, list(itertools.islice(p, n)))) (no-pygments25 !)