@@ -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 = [["观音\n Line2" , "Ποσειδῶν" ]]
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
280310def test_format_integer ():
0 commit comments