Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 2.14.0

(released on 2026-04-13)

- Downgrade Pygments requirement to v1.6+, and fix tests to support all versions.

## Version 2.13.0

(released on 2026-04-13)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ autopep8==1.3.3
codecov==2.1.13
coverage==4.3.4
black>=20.8b1
Pygments~=2.19.2
Pygments>=1.6
pytest==7.4.3
pytest-cov==2.4.0
Sphinx==1.5.5
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def open_file(filename):
"tabulate[widechars] ~= 0.10.0",
],
extras_require={
"styles": ["Pygments ~= 2.19.2"],
"styles": ["Pygments >= 1.6"],
},
python_requires=">=3.6",
classifiers=[
Expand Down
42 changes: 36 additions & 6 deletions tests/tabular_output/test_preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,24 @@
data = [["观音", "2"], ["Ποσειδῶν", "b"]]

expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
expected_data = [
# Pygments v2.19.2 and earlier
expected_data_old = [
["\x1b[38;5;233;48;5;7m观音\x1b[39;49m", "\x1b[38;5;233;48;5;7m2\x1b[39;49m"],
["\x1b[38;5;10mΠοσειδῶν\x1b[39m", "\x1b[38;5;10mb\x1b[39m"],
]
# Pygments v2.20.0 and later
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
expected_data_new = [
[
'\x1b[38;5;233;48;5;255m观音\x1b[39;49m',
'\x1b[38;5;233;48;5;255m2\x1b[39;49m',
],
['\x1b[38;5;10mΠοσειδῶν\x1b[39m', '\x1b[38;5;10mb\x1b[39m'],
]
results = style_output(data, headers, style=CliStyle)

assert (expected_data, expected_headers) == (list(results[0]), results[1])
assert results[1] == expected_headers
assert list(results[0]) in [expected_data_old, expected_data_new]


@pytest.mark.skipif(not HAS_PYGMENTS, reason="requires the Pygments library")
Expand All @@ -232,16 +243,27 @@
data = [["观音\nLine2", "Ποσειδῶν"]]

expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
expected_data = [
# Pygments v2.19.2 and earlier
expected_data_old = [
[
"\x1b[38;5;233;48;5;7m观音\x1b[39;49m\n\x1b[38;5;233;48;5;7m"
"Line2\x1b[39;49m",
"\x1b[38;5;233;48;5;7mΠοσειδῶν\x1b[39;49m",
]
]
# Pygments v2.20.0 and later
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
expected_data_new = [
[
'\x1b[38;5;233;48;5;255m观音\x1b[39;49m\n\x1b[38;5;233;48;5;255m'
'Line2\x1b[39;49m',

Check warning

Code scanning / CodeQL

Implicit string concatenation in a list Warning test

Implicit string concatenation. Maybe missing a comma?
'\x1b[38;5;233;48;5;255mΠοσειδῶν\x1b[39;49m',
]
]
results = style_output(data, headers, style=CliStyle)

assert (expected_data, expected_headers) == (list(results[0]), results[1])
assert results[1] == expected_headers
assert list(results[0]) in [expected_data_old, expected_data_new]


@pytest.mark.skipif(not HAS_PYGMENTS, reason="requires the Pygments library")
Expand All @@ -260,10 +282,17 @@
data = [["1", "2"], ["a", "b"]]

expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
expected_data = [
# Pygments v2.19.2 and earlier
expected_data_old = [
["\x1b[38;5;233;48;5;7m1\x1b[39;49m", "\x1b[38;5;233;48;5;7m2\x1b[39;49m"],
["\x1b[38;5;10ma\x1b[39m", "\x1b[38;5;10mb\x1b[39m"],
]
# Pygments v2.20.0 and later
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
expected_data_new = [
['\x1b[38;5;233;48;5;255m1\x1b[39;49m', '\x1b[38;5;233;48;5;255m2\x1b[39;49m'],
['\x1b[38;5;10ma\x1b[39m', '\x1b[38;5;10mb\x1b[39m'],
]

output = style_output(
data,
Expand All @@ -274,7 +303,8 @@
even_row_token=Token.Results.EvenRows,
)

assert (expected_data, expected_headers) == (list(output[0]), output[1])
assert output[1] == expected_headers
assert list(output[0]) in [expected_data_old, expected_data_new]


def test_format_integer():
Expand Down
Loading