# HG changeset patch # User Gregory Szorc # Date 1579371705 28800 # 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 -r f81c17ec303c -r 5b38c2ab6ad3 tests/hghave.py --- a/tests/hghave.py Mon Jan 20 23:51:25 2020 -0800 +++ b/tests/hghave.py Sat Jan 18 10:21:45 2020 -0800 @@ -577,6 +577,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("outer-repo", "outer repo") def has_outer_repo(): # failing for other reasons than 'no repo' imply that there is a repo diff -r f81c17ec303c -r 5b38c2ab6ad3 tests/test-highlight.t --- a/tests/test-highlight.t Mon Jan 20 23:51:25 2020 -0800 +++ b/tests/test-highlight.t Sat Jan 18 10:21:45 2020 -0800 @@ -184,7 +184,8 @@ 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 @@ 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 !)