@@ -3151,7 +3151,7 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
31513151 error_collector = ErrorCollector (self .assert_ )
31523152 cpplint .ProcessFileData (
31533153 'foo.cc' , 'cc' ,
3154- unicode ( raw_bytes , 'utf8 ' , 'replace' ).split ('\n ' ),
3154+ raw_bytes . decode ( 'utf-8 ' , errors = 'replace' ).split ('\n ' ),
31553155 error_collector )
31563156 # The warning appears only once.
31573157 self .assertEquals (
@@ -3161,12 +3161,12 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
31613161 ' (or Unicode replacement character).'
31623162 ' [readability/utf8] [5]' ))
31633163
3164- DoTest (self , 'Hello world\n ' , False )
3165- DoTest (self , '\xe9 \x8e \xbd \n ' , False )
3166- DoTest (self , '\xe9 x\x8e \xbd \n ' , True )
3164+ DoTest (self , b 'Hello world\n ' , False )
3165+ DoTest (self , b '\xe9 \x8e \xbd \n ' , False )
3166+ DoTest (self , b '\xe9 x\x8e \xbd \n ' , True )
31673167 # This is the encoding of the replacement character itself (which
31683168 # you can see by evaluating codecs.getencoder('utf8')(u'\ufffd')).
3169- DoTest (self , '\xef \xbf \xbd \n ' , True )
3169+ DoTest (self , b '\xef \xbf \xbd \n ' , True )
31703170
31713171 def testBadCharacters (self ):
31723172 # Test for NUL bytes only
@@ -3184,7 +3184,7 @@ def testBadCharacters(self):
31843184 cpplint .ProcessFileData (
31853185 'nul_utf8.cc' , 'cc' ,
31863186 ['// Copyright 2014 Your Company.' ,
3187- unicode ( '\xe9 x\0 ' , 'utf8' , 'replace' ), '' ],
3187+ b '\xe9 x\0 '. decode ( 'utf8' , errors = 'replace' ), '' ],
31883188 error_collector )
31893189 self .assertEquals (
31903190 error_collector .Results (),
@@ -5810,8 +5810,9 @@ def _runCppLint(self, *args):
58105810
58115811 def testNonQuietWithErrors (self ):
58125812 # This will fail: the test header is missing a copyright and header guard.
5813- (return_code , output ) = self ._runCppLint ()
5813+ (return_code , output_bytes ) = self ._runCppLint ()
58145814 self .assertEquals (1 , return_code )
5815+ output = output_bytes .decode ('utf-8' )
58155816 # Always-on behavior: Print error messages as they come up.
58165817 self .assertIn ("[legal/copyright]" , output )
58175818 self .assertIn ("[build/header_guard]" , output )
@@ -5821,7 +5822,8 @@ def testNonQuietWithErrors(self):
58215822
58225823 def testQuietWithErrors (self ):
58235824 # When there are errors, behavior is identical to not passing --quiet.
5824- (return_code , output ) = self ._runCppLint ('--quiet' )
5825+ (return_code , output_bytes ) = self ._runCppLint ('--quiet' )
5826+ output = output_bytes .decode ('utf-8' )
58255827 self .assertEquals (1 , return_code )
58265828 self .assertIn ("[legal/copyright]" , output )
58275829 self .assertIn ("[build/header_guard]" , output )
@@ -5831,9 +5833,10 @@ def testQuietWithErrors(self):
58315833
58325834 def testNonQuietWithoutErrors (self ):
58335835 # This will succeed. We filtered out all the known errors for that file.
5834- (return_code , output ) = self ._runCppLint ('--filter=' +
5835- '-legal/copyright,' +
5836- '-build/header_guard' )
5836+ (return_code , output_bytes ) = self ._runCppLint ('--filter=' +
5837+ '-legal/copyright,' +
5838+ '-build/header_guard' )
5839+ output = output_bytes .decode ('utf-8' )
58375840 self .assertEquals (0 , return_code , output )
58385841 # No cpplint errors are printed since there were no errors.
58395842 self .assertNotIn ("[legal/copyright]" , output )
@@ -5845,10 +5848,11 @@ def testNonQuietWithoutErrors(self):
58455848
58465849 def testQuietWithoutErrors (self ):
58475850 # This will succeed. We filtered out all the known errors for that file.
5848- (return_code , output ) = self ._runCppLint ('--quiet' ,
5849- '--filter=' +
5850- '-legal/copyright,' +
5851- '-build/header_guard' )
5851+ (return_code , output_bytes ) = self ._runCppLint ('--quiet' ,
5852+ '--filter=' +
5853+ '-legal/copyright,' +
5854+ '-build/header_guard' )
5855+ output = output_bytes .decode ('utf-8' )
58525856 self .assertEquals (0 , return_code , output )
58535857 # No cpplint errors are printed since there were no errors.
58545858 self .assertNotIn ("[legal/copyright]" , output )
0 commit comments