@@ -3071,7 +3071,7 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
3071
3071
error_collector = ErrorCollector (self .assert_ )
3072
3072
cpplint .ProcessFileData (
3073
3073
'foo.cc' , 'cc' ,
3074
- unicode ( raw_bytes , 'utf8 ' , 'replace' ).split ('\n ' ),
3074
+ raw_bytes . decode ( 'utf-8 ' , errors = 'replace' ).split ('\n ' ),
3075
3075
error_collector )
3076
3076
# The warning appears only once.
3077
3077
self .assertEquals (
@@ -3081,12 +3081,12 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
3081
3081
' (or Unicode replacement character).'
3082
3082
' [readability/utf8] [5]' ))
3083
3083
3084
- DoTest (self , 'Hello world\n ' , False )
3085
- DoTest (self , '\xe9 \x8e \xbd \n ' , False )
3086
- DoTest (self , '\xe9 x\x8e \xbd \n ' , True )
3084
+ DoTest (self , b 'Hello world\n ' , False )
3085
+ DoTest (self , b '\xe9 \x8e \xbd \n ' , False )
3086
+ DoTest (self , b '\xe9 x\x8e \xbd \n ' , True )
3087
3087
# This is the encoding of the replacement character itself (which
3088
3088
# you can see by evaluating codecs.getencoder('utf8')(u'\ufffd')).
3089
- DoTest (self , '\xef \xbf \xbd \n ' , True )
3089
+ DoTest (self , b '\xef \xbf \xbd \n ' , True )
3090
3090
3091
3091
def testBadCharacters (self ):
3092
3092
# Test for NUL bytes only
@@ -3104,7 +3104,7 @@ def testBadCharacters(self):
3104
3104
cpplint .ProcessFileData (
3105
3105
'nul_utf8.cc' , 'cc' ,
3106
3106
['// Copyright 2014 Your Company.' ,
3107
- unicode ( '\xe9 x\0 ' , 'utf8 ' , 'replace' ), '' ],
3107
+ b '\xe9 x\0 '. decode ( 'utf-8 ' , errors = 'replace' ), '' ],
3108
3108
error_collector )
3109
3109
self .assertEquals (
3110
3110
error_collector .Results (),
@@ -5723,8 +5723,9 @@ def _runCppLint(self, *args):
5723
5723
5724
5724
def testNonQuietWithErrors (self ):
5725
5725
# This will fail: the test header is missing a copyright and header guard.
5726
- (return_code , output ) = self ._runCppLint ()
5726
+ (return_code , output_bytes ) = self ._runCppLint ()
5727
5727
self .assertEquals (1 , return_code )
5728
+ output = output_bytes .decode ('utf-8' )
5728
5729
# Always-on behavior: Print error messages as they come up.
5729
5730
self .assertIn ("[legal/copyright]" , output )
5730
5731
self .assertIn ("[build/header_guard]" , output )
@@ -5734,7 +5735,8 @@ def testNonQuietWithErrors(self):
5734
5735
5735
5736
def testQuietWithErrors (self ):
5736
5737
# When there are errors, behavior is identical to not passing --quiet.
5737
- (return_code , output ) = self ._runCppLint ('--quiet' )
5738
+ (return_code , output_bytes ) = self ._runCppLint ('--quiet' )
5739
+ output = output_bytes .decode ('utf-8' )
5738
5740
self .assertEquals (1 , return_code )
5739
5741
self .assertIn ("[legal/copyright]" , output )
5740
5742
self .assertIn ("[build/header_guard]" , output )
@@ -5744,9 +5746,10 @@ def testQuietWithErrors(self):
5744
5746
5745
5747
def testNonQuietWithoutErrors (self ):
5746
5748
# This will succeed. We filtered out all the known errors for that file.
5747
- (return_code , output ) = self ._runCppLint ('--filter=' +
5748
- '-legal/copyright,' +
5749
- '-build/header_guard' )
5749
+ (return_code , output_bytes ) = self ._runCppLint ('--filter=' +
5750
+ '-legal/copyright,' +
5751
+ '-build/header_guard' )
5752
+ output = output_bytes .decode ('utf-8' )
5750
5753
self .assertEquals (0 , return_code , output )
5751
5754
# No cpplint errors are printed since there were no errors.
5752
5755
self .assertNotIn ("[legal/copyright]" , output )
@@ -5758,10 +5761,11 @@ def testNonQuietWithoutErrors(self):
5758
5761
5759
5762
def testQuietWithoutErrors (self ):
5760
5763
# This will succeed. We filtered out all the known errors for that file.
5761
- (return_code , output ) = self ._runCppLint ('--quiet' ,
5762
- '--filter=' +
5763
- '-legal/copyright,' +
5764
- '-build/header_guard' )
5764
+ (return_code , output_bytes ) = self ._runCppLint ('--quiet' ,
5765
+ '--filter=' +
5766
+ '-legal/copyright,' +
5767
+ '-build/header_guard' )
5768
+ output = output_bytes .decode ('utf-8' )
5765
5769
self .assertEquals (0 , return_code , output )
5766
5770
# No cpplint errors are printed since there were no errors.
5767
5771
self .assertNotIn ("[legal/copyright]" , output )
0 commit comments