-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix selftests with Pygments >= 2.19.0 #13113
Fix selftests with Pygments >= 2.19.0 #13113
Conversation
testing/conftest.py
Outdated
@@ -168,6 +170,9 @@ def color_mapping(): | |||
|
|||
Used by tests which check the actual colors output by pytest. | |||
""" | |||
# https://github.com/pygments/pygments/commit/d24e272894a56a98b1b718d9ac5fabc20124882a | |||
pygments_version = tuple(int(part) for part in pygments.__version__.split(".")[:2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit crude, I thought about using packaging.Version
instead (pytest already depends on it). Since we only need major/minor, I suppose this is simpler? Happy to adjust if preferred.
Alternatively we could just adjust this without a version check and assume the newest Pygments version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you, given these are self tests I'm OK with this solution... if it ever breaks we can just adjust it to something more elaborate with packaging.Version
. 👍
testing/conftest.py
Outdated
@@ -6,6 +6,8 @@ | |||
import re | |||
import sys | |||
|
|||
import pygments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the testsuite explicitly depend on pygments - but the tests in test_terminal.py
already fail if pygments
is not installed, and it's in optional-dependencies.dev
in pyproject.toml
, so I suppose that's alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me.
The alternative would be to import-or-skip inside the fixture function.
testing/conftest.py
Outdated
@@ -168,6 +170,9 @@ def color_mapping(): | |||
|
|||
Used by tests which check the actual colors output by pytest. | |||
""" | |||
# https://github.com/pygments/pygments/commit/d24e272894a56a98b1b718d9ac5fabc20124882a | |||
pygments_version = tuple(int(part) for part in pygments.__version__.split(".")[:2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fetch the version from Importlib.metadata.version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @The-Compiler for tackling this!
testing/conftest.py
Outdated
@@ -168,6 +170,9 @@ def color_mapping(): | |||
|
|||
Used by tests which check the actual colors output by pytest. | |||
""" | |||
# https://github.com/pygments/pygments/commit/d24e272894a56a98b1b718d9ac5fabc20124882a | |||
pygments_version = tuple(int(part) for part in pygments.__version__.split(".")[:2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you, given these are self tests I'm OK with this solution... if it ever breaks we can just adjust it to something more elaborate with packaging.Version
. 👍
With Pygments 2.19, the Python lexer now emits Text.Whitespace (rather than Text) tokens after "def", which get highlighted as "bright black". See pygments/pygments#1905 Fixes pytest-dev#13112
7972182
to
888cf3f
Compare
Updated to use |
for more information, see https://pre-commit.ci
Awesome, thanks! |
Backport to 8.3.x: 💚 backport PR created✅ Backport PR branch: Backported as #13116 🤖 @patchback |
Fix selftests with Pygments >= 2.19.0 (cherry picked from commit bdfc3a9)
…dfc3a99bd733f385f150446caef6d5843bb6418/pr-13113 [PR #13113/bdfc3a99 backport][8.3.x] Fix selftests with Pygments >= 2.19.0
With Pygments 2.19, the Python lexer now emits
Text.Whitespace (rather than Text) tokens after "def", which get highlighted as "bright black".
See pygments/pygments#1905
Fixes #13112
(also fixes the current CI failures, I hope!)