pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

Tests break against python3-pygments (=2.10.0+dfsg-1) #234

Closed AlexGhiti closed 2 years ago

AlexGhiti commented 2 years ago

Hi,

We (Debian/Ubuntu) are updating python3-pygments to 2.10, but then it breaks pygments.rb package as reported here [1]. I tried to update the pygments.rb package to 2.2.0, and then the only remaining failures are related to UTF-8 expected encoding whereas ASCII is provided.

Could you give us a hand to fix those failures?

Thanks!

[1] https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1835947.html

Failure: test_lexer_by_content(PygmentsLexerTest)
/root/pygments.rb/test/test_pygments.rb:143:in `test_lexer_by_content'
     140:   end
     141: 
     142:   def test_lexer_by_content
  => 143:     assert_equal 'rb', P.lexer_name_for(RUBY_CODE)
     144:   end
     145: 
     146:   def test_lexer_by_nothing
<"rb">(UTF-8) expected but was
<"ruby">(ASCII-8BIT)

diff:
? ruby

? Encoding: UTF  -8   
?           ASCII  BIT
===========================================================================================================================================
F
===========================================================================================================================================
Failure: test_lexer_by_filename(PygmentsLexerTest)
/root/pygments.rb/test/test_pygments.rb:128:in `test_lexer_by_filename'
     125:   end
     126: 
     127:   def test_lexer_by_filename
  => 128:     assert_equal 'rb', P.lexer_name_for(filename: 'test.rb')
     129:     assert_equal 'scala', P.lexer_name_for(filename: 'test.scala')
     130:   end
     131: 
<"rb">(UTF-8) expected but was
<"ruby">(ASCII-8BIT)

diff:
? ruby

? Encoding: UTF  -8   
?           ASCII  BIT
===========================================================================================================================================
F
===========================================================================================================================================
Failure: test_lexer_by_filename_and_content(PygmentsLexerTest)
/root/pygments.rb/test/test_pygments.rb:139:in `test_lexer_by_filename_and_content'
     136:   end
     137: 
     138:   def test_lexer_by_filename_and_content
  => 139:     assert_equal 'rb', P.lexer_name_for(RUBY_CODE, filename: 'test.rb')
     140:   end
     141: 
     142:   def test_lexer_by_content
<"rb">(UTF-8) expected but was
<"ruby">(ASCII-8BIT)

diff:
? ruby

? Encoding: UTF  -8   
?           ASCII  BIT
===========================================================================================================================================
F
===========================================================================================================================================
Failure: test_lexer_by_mimetype(PygmentsLexerTest)
/root/pygments.rb/test/test_pygments.rb:123:in `test_lexer_by_mimetype'
     120:   RUBY_CODE = "#!/usr/bin/ruby\nputs 'foo'"
     121: 
     122:   def test_lexer_by_mimetype
  => 123:     assert_equal 'rb', P.lexer_name_for(mimetype: 'text/x-ruby')
     124:     assert_equal 'json', P.lexer_name_for(mimetype: 'application/json')
     125:   end
     126: 
<"rb">(UTF-8) expected but was
<"ruby">(ASCII-8BIT)

diff:
? ruby

? Encoding: UTF  -8   
?           ASCII  BIT
===========================================================================================================================================
F
===========================================================================================================================================
Failure: test_lexer_by_name(PygmentsLexerTest)
/root/pygments.rb/test/test_pygments.rb:133:in `test_lexer_by_name'
     130:   end
     131: 
     132:   def test_lexer_by_name
  => 133:     assert_equal 'rb', P.lexer_name_for(lexer: 'ruby')
     134:     assert_equal 'python', P.lexer_name_for(lexer: 'python')
     135:     assert_equal 'c', P.lexer_name_for(lexer: 'c')
     136:   end
<"rb">(UTF-8) expected but was
<"ruby">(ASCII-8BIT)

diff:
? ruby

? Encoding: UTF  -8   
?           ASCII  BIT
slonopotamus commented 2 years ago

I believe it was this change: https://github.com/pygments/pygments/pull/1780/files#diff-8b5c2178a004022575a5a9e7dc5184d9bf3355ab9d7f45be7b14a9e6a6f9f8d1L36

I'll adjust our tests.

For the history: the problem is not UTF-8 vs ASCII. The problem is rb vs ruby.

slonopotamus commented 2 years ago

Fixed and released: https://github.com/pygments/pygments.rb/releases/tag/v2.3.0