@@ -3151,7 +3151,7 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
3151
3151
error_collector = ErrorCollector (self .assert_ )
3152
3152
cpplint .ProcessFileData (
3153
3153
'foo.cc' , 'cc' ,
3154
- unicode ( raw_bytes , 'utf8 ' , 'replace' ).split ('\n ' ),
3154
+ raw_bytes . decode ( 'utf-8 ' , errors = 'replace' ).split ('\n ' ),
3155
3155
error_collector )
3156
3156
# The warning appears only once.
3157
3157
self .assertEquals (
@@ -3161,12 +3161,12 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
3161
3161
' (or Unicode replacement character).'
3162
3162
' [readability/utf8] [5]' ))
3163
3163
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 )
3167
3167
# This is the encoding of the replacement character itself (which
3168
3168
# 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 )
3170
3170
3171
3171
def testBadCharacters (self ):
3172
3172
# Test for NUL bytes only
@@ -3184,7 +3184,7 @@ def testBadCharacters(self):
3184
3184
cpplint .ProcessFileData (
3185
3185
'nul_utf8.cc' , 'cc' ,
3186
3186
['// Copyright 2014 Your Company.' ,
3187
- unicode ( '\xe9 x\0 ' , 'utf8' , 'replace' ), '' ],
3187
+ b '\xe9 x\0 '. decode ( 'utf8' , errors = 'replace' ), '' ],
3188
3188
error_collector )
3189
3189
self .assertEquals (
3190
3190
error_collector .Results (),
@@ -5810,8 +5810,9 @@ def _runCppLint(self, *args):
5810
5810
5811
5811
def testNonQuietWithErrors (self ):
5812
5812
# 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 ()
5814
5814
self .assertEquals (1 , return_code )
5815
+ output = output_bytes .decode ('utf-8' )
5815
5816
# Always-on behavior: Print error messages as they come up.
5816
5817
self .assertIn ("[legal/copyright]" , output )
5817
5818
self .assertIn ("[build/header_guard]" , output )
@@ -5821,7 +5822,8 @@ def testNonQuietWithErrors(self):
5821
5822
5822
5823
def testQuietWithErrors (self ):
5823
5824
# 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' )
5825
5827
self .assertEquals (1 , return_code )
5826
5828
self .assertIn ("[legal/copyright]" , output )
5827
5829
self .assertIn ("[build/header_guard]" , output )
@@ -5831,9 +5833,10 @@ def testQuietWithErrors(self):
5831
5833
5832
5834
def testNonQuietWithoutErrors (self ):
5833
5835
# 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' )
5837
5840
self .assertEquals (0 , return_code , output )
5838
5841
# No cpplint errors are printed since there were no errors.
5839
5842
self .assertNotIn ("[legal/copyright]" , output )
@@ -5845,10 +5848,11 @@ def testNonQuietWithoutErrors(self):
5845
5848
5846
5849
def testQuietWithoutErrors (self ):
5847
5850
# 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' )
5852
5856
self .assertEquals (0 , return_code , output )
5853
5857
# No cpplint errors are printed since there were no errors.
5854
5858
self .assertNotIn ("[legal/copyright]" , output )
0 commit comments