Skip to content

Commit 05a2c58

Browse files
authored
revert Pygments upgrade (#112)
and make tests which include control sequences more robust. The assumption is that pygments/pygments#3043 caused the control sequences to change, but that is a pure assumption. The revert seems needed because this repo advertises Python 3.6+ support, but the latest Pygments only supports Python 3.9+.
1 parent cf72abb commit 05a2c58

4 files changed

Lines changed: 44 additions & 8 deletions

File tree

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 2.14.0
4+
5+
(released on 2026-04-13)
6+
7+
- Downgrade Pygments requirement to v1.6+, and fix tests to support all versions.
8+
39
## Version 2.13.0
410

511
(released on 2026-04-13)

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ autopep8==1.3.3
22
codecov==2.1.13
33
coverage==4.3.4
44
black>=20.8b1
5-
Pygments~=2.19.2
5+
Pygments>=1.6
66
pytest==7.4.3
77
pytest-cov==2.4.0
88
Sphinx==1.5.5

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def open_file(filename):
4040
"tabulate[widechars] ~= 0.10.0",
4141
],
4242
extras_require={
43-
"styles": ["Pygments ~= 2.19.2"],
43+
"styles": ["Pygments >= 1.6"],
4444
},
4545
python_requires=">=3.6",
4646
classifiers=[

tests/tabular_output/test_preprocessors.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,24 @@ class CliStyle(Style):
207207
data = [["观音", "2"], ["Ποσειδῶν", "b"]]
208208

209209
expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
210-
expected_data = [
210+
# Pygments v2.19.2 and earlier
211+
expected_data_old = [
211212
["\x1b[38;5;233;48;5;7m观音\x1b[39;49m", "\x1b[38;5;233;48;5;7m2\x1b[39;49m"],
212213
["\x1b[38;5;10mΠοσειδῶν\x1b[39m", "\x1b[38;5;10mb\x1b[39m"],
213214
]
215+
# Pygments v2.20.0 and later
216+
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
217+
expected_data_new = [
218+
[
219+
'\x1b[38;5;233;48;5;255m观音\x1b[39;49m',
220+
'\x1b[38;5;233;48;5;255m2\x1b[39;49m',
221+
],
222+
['\x1b[38;5;10mΠοσειδῶν\x1b[39m', '\x1b[38;5;10mb\x1b[39m'],
223+
]
214224
results = style_output(data, headers, style=CliStyle)
215225

216-
assert (expected_data, expected_headers) == (list(results[0]), results[1])
226+
assert results[1] == expected_headers
227+
assert list(results[0]) in [expected_data_old, expected_data_new]
217228

218229

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

234245
expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
235-
expected_data = [
246+
# Pygments v2.19.2 and earlier
247+
expected_data_old = [
236248
[
237249
"\x1b[38;5;233;48;5;7m观音\x1b[39;49m\n\x1b[38;5;233;48;5;7m"
238250
"Line2\x1b[39;49m",
239251
"\x1b[38;5;233;48;5;7mΠοσειδῶν\x1b[39;49m",
240252
]
241253
]
254+
# Pygments v2.20.0 and later
255+
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
256+
expected_data_new = [
257+
[
258+
'\x1b[38;5;233;48;5;255m观音\x1b[39;49m\n\x1b[38;5;233;48;5;255m'
259+
'Line2\x1b[39;49m',
260+
'\x1b[38;5;233;48;5;255mΠοσειδῶν\x1b[39;49m',
261+
]
262+
]
242263
results = style_output(data, headers, style=CliStyle)
243264

244-
assert (expected_data, expected_headers) == (list(results[0]), results[1])
265+
assert results[1] == expected_headers
266+
assert list(results[0]) in [expected_data_old, expected_data_new]
245267

246268

247269
@pytest.mark.skipif(not HAS_PYGMENTS, reason="requires the Pygments library")
@@ -260,10 +282,17 @@ class CliStyle(Style):
260282
data = [["1", "2"], ["a", "b"]]
261283

262284
expected_headers = ["\x1b[91;01mh1\x1b[39;00m", "\x1b[91;01mh2\x1b[39;00m"]
263-
expected_data = [
285+
# Pygments v2.19.2 and earlier
286+
expected_data_old = [
264287
["\x1b[38;5;233;48;5;7m1\x1b[39;49m", "\x1b[38;5;233;48;5;7m2\x1b[39;49m"],
265288
["\x1b[38;5;10ma\x1b[39m", "\x1b[38;5;10mb\x1b[39m"],
266289
]
290+
# Pygments v2.20.0 and later
291+
# it looks like the control sequences changed after https://github.com/pygments/pygments/pull/3043
292+
expected_data_new = [
293+
['\x1b[38;5;233;48;5;255m1\x1b[39;49m', '\x1b[38;5;233;48;5;255m2\x1b[39;49m'],
294+
['\x1b[38;5;10ma\x1b[39m', '\x1b[38;5;10mb\x1b[39m'],
295+
]
267296

268297
output = style_output(
269298
data,
@@ -274,7 +303,8 @@ class CliStyle(Style):
274303
even_row_token=Token.Results.EvenRows,
275304
)
276305

277-
assert (expected_data, expected_headers) == (list(output[0]), output[1])
306+
assert output[1] == expected_headers
307+
assert list(output[0]) in [expected_data_old, expected_data_new]
278308

279309

280310
def test_format_integer():

0 commit comments

Comments
 (0)