diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-25 01:13:47 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-25 01:13:47 +0100 |
commit | 3d8365a7c8ecd165cef630cc33244e6f3bc9085f (patch) | |
tree | 2e80e44db836ba38b5f10883ed92a0e5cac437d5 /testsuite | |
parent | 69259deba15894a169d288da6c3dd9780b2451f9 (diff) | |
parent | 63a0a02d9dc521b6355210c60997d9e787814232 (diff) | |
download | pep8-3d8365a7c8ecd165cef630cc33244e6f3bc9085f.tar.gz |
Merge branch 'master' into issue126
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/E10.py | 36 | ||||
-rw-r--r-- | testsuite/E12.py | 239 | ||||
-rw-r--r-- | testsuite/E12not.py | 88 | ||||
-rw-r--r-- | testsuite/E21.py | 2 | ||||
-rw-r--r-- | testsuite/E22.py | 18 | ||||
-rw-r--r-- | testsuite/E24.py | 2 | ||||
-rw-r--r-- | testsuite/E25.py | 4 | ||||
-rw-r--r-- | testsuite/E70.py | 4 | ||||
-rw-r--r-- | testsuite/E71.py | 36 | ||||
-rw-r--r-- | testsuite/E72.py | 2 | ||||
-rw-r--r-- | testsuite/E90.py | 4 | ||||
-rw-r--r-- | testsuite/W19.py | 29 | ||||
-rw-r--r-- | testsuite/W60.py | 1 | ||||
-rw-r--r-- | testsuite/support.py | 19 | ||||
-rw-r--r-- | testsuite/test_api.py | 70 | ||||
-rw-r--r-- | testsuite/test_shell.py | 9 | ||||
-rw-r--r-- | testsuite/utf-8-bom.py | 6 |
17 files changed, 435 insertions, 134 deletions
diff --git a/testsuite/E10.py b/testsuite/E10.py index 784b59a..cd142e3 100644 --- a/testsuite/E10.py +++ b/testsuite/E10.py @@ -3,3 +3,39 @@ for a in 'abc': for b in 'xyz': print a # indented with 8 spaces print b # indented with 1 tab +#: E101 E122 W191 W191 +if True: + pass + +change_2_log = \ +"""Change 2 by slamb@testclient on 2006/04/13 21:46:23 + + creation +""" + +p4change = { + 2: change_2_log, +} + + +class TestP4Poller(unittest.TestCase): + def setUp(self): + self.setUpGetProcessOutput() + return self.setUpChangeSource() + + def tearDown(self): + pass + +# +#: E101 W191 W191 +if True: + foo(1, + 2) +#: E101 E101 W191 W191 +def test_keys(self): + """areas.json - All regions are accounted for.""" + expected = set([ + u'Norrbotten', + u'V\xe4sterbotten', + ]) +#: diff --git a/testsuite/E12.py b/testsuite/E12.py index 191e1f1..1328091 100644 --- a/testsuite/E12.py +++ b/testsuite/E12.py @@ -4,6 +4,11 @@ print "E121", ( #: E122 print "E122", ( "dent") +#: E123 +my_list = [ + 1, 2, 3, + 4, 5, 6, + ] #: E124 print "E124", ("visual", "indent_two" @@ -37,38 +42,136 @@ print "E128", ("under-", #: -#: E123 W291 -print "E123", ( - "bad", "hanging", "close" - ) -# -#: E123 -result = { - 'foo': [ - 'bar', { - 'baz': 'frop', - } - ] - } +#: E121 +my_list = [ + 1, 2, 3, + 4, 5, 6, + ] #: E121 result = { 'key1': 'value', 'key2': 'value', } -#: E121 +#: E121 E121 rv.update(dict.fromkeys(( 'qualif_nr', 'reasonComment_en', 'reasonComment_fr', 'reasonComment_de', 'reasonComment_it'), '?'), "foo") -#: E121 +#: E121 E121 abricot = 3 + \ 4 + \ 5 + 6 -#: E126 -abris = 3 + \ - 4 + \ - 5 + 6 +#: E121 +print "hello", ( + + "there", + # "john", + "dude") +#: E121 +part = set_mimetype(( + a.get('mime_type', 'text')), + 'default') +#: + + +#: E122 +if True: + result = some_function_that_takes_arguments( + 'a', 'b', 'c', + 'd', 'e', 'f', +) +#: E122 +if some_very_very_very_long_variable_name or var \ +or another_very_long_variable_name: + raise Exception() +#: E122 +if some_very_very_very_long_variable_name or var[0] \ +or another_very_long_variable_name: + raise Exception() +#: E122 +if True: + if some_very_very_very_long_variable_name or var \ + or another_very_long_variable_name: + raise Exception() +#: E122 +if True: + if some_very_very_very_long_variable_name or var[0] \ + or another_very_long_variable_name: + raise Exception() +#: E122 +dictionary = [ + "is": { + "nested": yes(), + }, +] +#: E122 +setup('', + scripts=[''], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + ]) +#: + + +#: E123 W291 +print "E123", ( + "bad", "hanging", "close" + ) +# +#: E123 E123 E123 +result = { + 'foo': [ + 'bar', { + 'baz': 'frop', + } + ] + } +#: E123 +result = some_function_that_takes_arguments( + 'a', 'b', 'c', + 'd', 'e', 'f', + ) +#: E124 +my_list = [1, 2, 3, + 4, 5, 6, +] +#: E124 +my_list = [1, 2, 3, + 4, 5, 6, + ] +#: E124 +result = some_function_that_takes_arguments('a', 'b', 'c', + 'd', 'e', 'f', +) +#: E124 +fooff(aaaa, + cca( + vvv, + dadd + ), fff, +) +#: E124 +fooff(aaaa, + ccaaa( + vvv, + dadd + ), + fff, +) +#: E124 +d = dict('foo', + help="exclude files or directories which match these " + "comma separated patterns (default: %s)" % DEFAULT_EXCLUDE + ) +#: E124 E128 E128 +if line_removed: + self.event(cr, uid, + name="Removing the option for contract", + description="contract line has been removed", + ) #: @@ -101,9 +204,18 @@ if (a == 2 or #: E126 +my_list = [ + 1, 2, 3, + 4, 5, 6, + ] +#: E126 E126 +abris = 3 + \ + 4 + \ + 5 + 6 +#: E126 fixed = re.sub(r'\t+', ' ', target[c::-1], 1)[::-1] + \ target[c + 1:] -#: E126 +#: E126 E126 rv.update(dict.fromkeys(( 'qualif_nr', 'reasonComment_en', 'reasonComment_fr', 'reasonComment_de', 'reasonComment_it'), @@ -130,6 +242,12 @@ if ( ) or y == 4): pass +#: E126 +troublesome_hash = { + "hash": "value", + "long": "the quick brown fox jumps over the lazy dog before doing a " + "somersault", +} #: @@ -150,43 +268,6 @@ def qualify_by_address(self, cr, uid, ids, context=None, #: -#: E121 -print "hello", ( - - "there", - # "john", - "dude") -#: E121 -part = set_mimetype(( - a.get('mime_type', 'text')), - 'default') -#: E124 -fooff(aaaa, - cca( - vvv, - dadd - ), fff, -) -#: E124 -fooff(aaaa, - ccaaa( - vvv, - dadd - ), - fff, -) -#: E126 -troublesome_hash = { - "hash": "value", - "long": "the quick brown fox jumps over the lazy dog before doing a " - "somersault", -} -#: E126 -# probably not easily fixed, without using 'ast' -troublesome_hash_ii = { - "long key that tends to happen more when you're indented": - "stringwithalongtoken you don't want to break", -} #: E128 foo(1, 2, 3, 4, 5, 6) @@ -226,24 +307,13 @@ foo(1, 2, 3, #: E127 foo(1, 2, 3, 4, 5, 6) -#: E124 -d = dict('foo', - help="exclude files or directories which match these " - "comma separated patterns (default: %s)" % DEFAULT_EXCLUDE - ) -#: E124 E128 -if line_removed: - self.event(cr, uid, - name="Removing the option for contract", - description="contract line has been removed", - ) -#: E128 +#: E128 E128 if line_removed: self.event(cr, uid, name="Removing the option for contract", description="contract line has been removed", ) -#: E124 E127 +#: E124 E127 E127 if line_removed: self.event(cr, uid, name="Removing the option for contract", @@ -264,22 +334,17 @@ input1 = {'a': {'calc': 1 + 2}, 'b': 1 rv.update(d=('a' + 'b', 'c'), e=42, f=(42 + 42)) -#: E122 -if some_very_very_very_long_variable_name or var \ -or another_very_long_variable_name: - raise Exception() -#: E122 -if some_very_very_very_long_variable_name or var[0] \ -or another_very_long_variable_name: - raise Exception() -#: E122 -if True: - if some_very_very_very_long_variable_name or var \ - or another_very_long_variable_name: - raise Exception() -#: E122 +#: E123 if True: - if some_very_very_very_long_variable_name or var[0] \ - or another_very_long_variable_name: - raise Exception() + def example_issue254(): + return [node.copy( + ( + replacement + # First, look at all the node's current children. + for child in node.children + # Replace them. + for replacement in replace(child) + ), + dict(name=token.undefined) + )] #: diff --git a/testsuite/E12not.py b/testsuite/E12not.py index 9509379..733b424 100644 --- a/testsuite/E12not.py +++ b/testsuite/E12not.py @@ -128,7 +128,7 @@ part = [-1, (2, 3, fnct(1, 2, 3, 4, 5, 6) -fnct(1, 2, 3 +fnct(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) @@ -546,3 +546,89 @@ if a > b and \ c > d: moo_like_a_cow() # +my_list = [ + 1, 2, 3, + 4, 5, 6, +] + +my_list = [1, 2, 3, + 4, 5, 6, + ] + +result = some_function_that_takes_arguments( + 'a', 'b', 'c', + 'd', 'e', 'f', +) + +result = some_function_that_takes_arguments('a', 'b', 'c', + 'd', 'e', 'f', + ) + +# issue 203 +dica = { + ('abc' + 'def'): ( + 'abc'), +} + +(abcdef[0] + [1]) = ( + 'abc') + +('abc' + 'def') == ( + 'abc') + +# issue 214 +bar( + 1).zap( + 2) + +bar( + 1).zap( + 2) +# +if True: + + def example_issue254(): + return [node.copy( + ( + replacement + # First, look at all the node's current children. + for child in node.children + # Replace them. + for replacement in replace(child) + ), + dict(name=token.undefined) + )] + + +def valid_example(): + return [node.copy(properties=dict( + (key, val if val is not None else token.undefined) + for key, val in node.items() + ))] + + +def other_example(): + return [node.copy(properties=dict( + (key, val if val is not None else token.undefined) + for key, val in node.items() + ))] + +foo([ + 'bug' +]) + +# issue 144, finally! +some_hash = { + "long key that tends to happen more when you're indented": + "stringwithalongtoken you don't want to break", +} + +{ + 1: + 999999 if True + else 0, +} +# diff --git a/testsuite/E21.py b/testsuite/E21.py index e830895..96b55b8 100644 --- a/testsuite/E21.py +++ b/testsuite/E21.py @@ -1,6 +1,6 @@ #: E211 spam (1) -#: E211 +#: E211 E211 dict ['key'] = list [index] #: E211 dict['key'] ['subkey'] = list[index] diff --git a/testsuite/E22.py b/testsuite/E22.py index ba93d41..f7eeaa0 100644 --- a/testsuite/E22.py +++ b/testsuite/E22.py @@ -1,15 +1,15 @@ #: E221 a = 12 + 3 b = 4 + 5 -#: E221 +#: E221 E221 x = 1 y = 2 long_variable = 3 -#: E221 +#: E221 E221 x[0] = 1 x[1] = 2 long_variable = 3 -#: E221 +#: E221 E221 x = f(x) + 1 y = long_variable + 2 z = x[0] + 3 @@ -23,11 +23,11 @@ long_variable = 3 #: E222 a = a + 1 b = b + 10 -#: E222 +#: E222 E222 x = -1 y = -2 long_variable = 3 -#: E222 +#: E222 E222 x[0] = 1 x[1] = 2 long_variable = 3 @@ -68,9 +68,9 @@ z = (x + 1)** y _1kB = _1MB >>10 #: E225 _1kB = _1MB>> 10 -#: E225 +#: E225 E225 i=i+ 1 -#: E225 +#: E225 E225 i=i +1 #: E225 E226 i=i+1 @@ -86,7 +86,7 @@ c = (a+ b)*(a - b) #: E226 z = 2**30 -#: E226 +#: E226 E226 c = (a+b) * (a-b) #: E226 norman = True+False @@ -94,7 +94,7 @@ norman = True+False x = x*2 - 1 #: E226 x = x/2 - 1 -#: E226 +#: E226 E226 hypot2 = x*x + y*y #: E226 c = (a + b)*(a - b) diff --git a/testsuite/E24.py b/testsuite/E24.py index 9ca8e2b..36fb4aa 100644 --- a/testsuite/E24.py +++ b/testsuite/E24.py @@ -6,7 +6,7 @@ b = (1, 20) a = (1, 2) # tab before 2 #: Okay b = (1, 20) # space before 20 -#: E241 +#: E241 E241 E241 # issue 135 more_spaces = [a, b, ef, +h, diff --git a/testsuite/E25.py b/testsuite/E25.py index 94154bf..b8031ec 100644 --- a/testsuite/E25.py +++ b/testsuite/E25.py @@ -1,4 +1,4 @@ -#: E251 +#: E251 E251 def foo(bar = False): '''Test function with an error in declaration''' pass @@ -6,7 +6,7 @@ def foo(bar = False): foo(bar= True) #: E251 foo(bar =True) -#: E251 +#: E251 E251 foo(bar = True) #: E251 y = bar(root= "sdasd") diff --git a/testsuite/E70.py b/testsuite/E70.py index 8941ab1..64feefd 100644 --- a/testsuite/E70.py +++ b/testsuite/E70.py @@ -1,9 +1,13 @@ #: E701 if a: a = False +#: E701 +if not header or header[:6] != 'bytes=': return #: E702 a = False; b = True #: E702 import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) #: E703 import shlex; +#: E702 E703 +del a[:]; a.append(42); #: diff --git a/testsuite/E71.py b/testsuite/E71.py index 645d2d7..2ff5dea 100644 --- a/testsuite/E71.py +++ b/testsuite/E71.py @@ -1,9 +1,41 @@ +#: E711 +if res == None: + pass #: E712 if res == True: pass #: E712 if res != False: pass -#: E711 -if res == None: + +# +#: E713 +if not X in Y: + pass +#: E713 +if not X.B in Y: + pass +#: E713 +if not X in Y and Z == "zero": + pass +#: E713 +if X == "zero" or not Y in Z: + pass + +# +#: E714 +if not X is Y: + pass +#: E714 +if not X.B is Y: + pass +#: Okay +if x not in y: + pass +if not (X in Y or X is Z): + pass +if not (X in Y): + pass +if x is not y: pass +#: diff --git a/testsuite/E72.py b/testsuite/E72.py index 514995a..8eb34cb 100644 --- a/testsuite/E72.py +++ b/testsuite/E72.py @@ -32,7 +32,7 @@ assert type(res) is type((1, )) assert type(res) is not type((1, )) #: E211 E721 assert type(res) == type ([2, ]) -#: E201 E202 E721 +#: E201 E201 E202 E721 assert type(res) == type( ( ) ) #: E201 E202 E721 assert type(res) == type( (0, ) ) diff --git a/testsuite/E90.py b/testsuite/E90.py index 1371e31..2d0b2dc 100644 --- a/testsuite/E90.py +++ b/testsuite/E90.py @@ -2,13 +2,13 @@ } #: E901 = [x -#: E901 E101 W191 +#: E901 E101 W191 W191 while True: try: pass except: print 'Whoops' -#: E122 E225 E251 E701 +#: E122 E225 E251 E251 E701 # Do not crash if code is invalid if msg: diff --git a/testsuite/W19.py b/testsuite/W19.py index c81f46f..3e303d9 100644 --- a/testsuite/W19.py +++ b/testsuite/W19.py @@ -4,7 +4,7 @@ if False: #: -#: E126 W191 +#: W191 y = x == 2 \ or x == 3 #: E101 W191 @@ -38,7 +38,7 @@ if ( pass #: -#: E101 W191 +#: E101 E101 W191 W191 if start[1] > end_col and not ( over_indent == 4 and indent_next): return(0, "E121 continuation line over-" @@ -56,7 +56,7 @@ def long_function_name( if ((row < 0 or self.moduleCount <= row or col < 0 or self.moduleCount <= col)): raise Exception("%s,%s - %s" % (row, col, self.moduleCount)) -#: E101 W191 +#: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 if bar: return( start, 'E121 lines starting with a ' @@ -86,14 +86,14 @@ if (a == 2 or b == """abc def ghi jkl mno"""): return True -#: E101 W191 +#: E101 W191 W191 if length > options.max_line_length: return options.max_line_length, \ "E501 line too long (%d characters)" % length # -#: E101 W191 +#: E101 W191 W191 if os.path.exists(os.path.join(path, PEP8_BIN)): cmd = ([os.path.join(path, PEP8_BIN)] + self._pep8_options(targetfile)) @@ -101,4 +101,23 @@ if os.path.exists(os.path.join(path, PEP8_BIN)): if foo is None and bar is "frop" and \ blah == 'yeah': blah = 'yeahnah' + + +# +#: W191 W191 W191 +if True: + foo( + 1, + 2) +#: W191 W191 W191 W191 W191 +def test_keys(self): + """areas.json - All regions are accounted for.""" + expected = set([ + u'Norrbotten', + u'V\xe4sterbotten', + ]) +#: W191 +x = [ + 'abc' +] #: diff --git a/testsuite/W60.py b/testsuite/W60.py index 6d819ee..973d22f 100644 --- a/testsuite/W60.py +++ b/testsuite/W60.py @@ -7,6 +7,7 @@ raise DummyError, "Message" raise ValueError, "hello %s %s" % (1, 2) #: Okay raise type_, val, tb +raise Exception, Exception("f"), t #: W603 if x <> 0: x = 0 diff --git a/testsuite/support.py b/testsuite/support.py index 4bd3067..d4acba6 100644 --- a/testsuite/support.py +++ b/testsuite/support.py @@ -28,21 +28,28 @@ class TestReport(StandardReport): def get_file_results(self): # Check if the expected errors were found label = '%s:%s:1' % (self.filename, self.line_offset) - codes = sorted(self.expected) - for code in codes: + for code in self.expected: if not self.counters.get(code): self.file_errors += 1 self.total_errors += 1 print('%s: error %s not found' % (label, code)) + else: + self.counters[code] -= 1 + for code, extra in sorted(self.counters.items()): + if code not in self._benchmark_keys: + if extra and code in self.expected: + self.file_errors += 1 + self.total_errors += 1 + print('%s: error %s found too many times (+%d)' % + (label, code, extra)) + # Reset counters + del self.counters[code] if self._verbose and not self.file_errors: print('%s: passed (%s)' % - (label, ' '.join(codes) or 'Okay')) + (label, ' '.join(self.expected) or 'Okay')) self.counters['test cases'] += 1 if self.file_errors: self.counters['failed tests'] += 1 - # Reset counters - for key in set(self.counters) - set(self._benchmark_keys): - del self.counters[key] self.messages = {} return super(TestReport, self).get_file_results() diff --git a/testsuite/test_api.py b/testsuite/test_api.py index a31ff42..313fd93 100644 --- a/testsuite/test_api.py +++ b/testsuite/test_api.py @@ -10,6 +10,15 @@ from testsuite.support import ROOT_DIR, PseudoFile E11 = os.path.join(ROOT_DIR, 'testsuite', 'E11.py') +class DummyChecker(object): + def __init__(self, tree, filename): + pass + + def run(self): + if False: + yield + + class APITestCase(unittest.TestCase): """Test the public methods.""" @@ -68,13 +77,6 @@ class APITestCase(unittest.TestCase): for name, func, args in options.logical_checks)) def test_register_ast_check(self): - class DummyChecker(object): - def __init__(self, tree, filename): - pass - - def run(self): - if False: - yield pep8.register_check(DummyChecker, ['Z701']) self.assertTrue(DummyChecker in pep8._checks['tree']) @@ -87,18 +89,14 @@ class APITestCase(unittest.TestCase): for name, cls, args in options.ast_checks)) def test_register_invalid_check(self): - class DummyChecker(object): + class InvalidChecker(DummyChecker): def __init__(self, filename): pass - def run(self): - if False: - yield - def check_dummy(logical, tokens): if False: yield - pep8.register_check(DummyChecker, ['Z741']) + pep8.register_check(InvalidChecker, ['Z741']) pep8.register_check(check_dummy, ['Z441']) for checkers in pep8._checks.values(): @@ -180,7 +178,7 @@ class APITestCase(unittest.TestCase): options = parse_argv('').options self.assertEqual(options.select, ()) - self.assertEqual(options.ignore, ('E226', 'E24')) + self.assertEqual(options.ignore, ('E123', 'E226', 'E24')) options = parse_argv('--doctest').options self.assertEqual(options.select, ()) @@ -194,6 +192,18 @@ class APITestCase(unittest.TestCase): self.assertEqual(options.select, ('E', 'W')) self.assertEqual(options.ignore, ('',)) + options = parse_argv('--select E --ignore E24').options + self.assertEqual(options.select, ('E',)) + self.assertEqual(options.ignore, ('',)) + + options = parse_argv('--ignore E --select E24').options + self.assertEqual(options.select, ('E24',)) + self.assertEqual(options.ignore, ('',)) + + options = parse_argv('--ignore W --select E24').options + self.assertEqual(options.select, ('E24',)) + self.assertEqual(options.ignore, ('',)) + pep8style = pep8.StyleGuide(paths=[E11]) self.assertFalse(pep8style.ignore_code('E112')) self.assertFalse(pep8style.ignore_code('W191')) @@ -209,6 +219,13 @@ class APITestCase(unittest.TestCase): self.assertFalse(pep8style.ignore_code('W191')) self.assertTrue(pep8style.ignore_code('E241')) + pep8style = pep8.StyleGuide(select=('F401',), paths=[E11]) + self.assertEqual(pep8style.options.select, ('F401',)) + self.assertEqual(pep8style.options.ignore, ('',)) + self.assertFalse(pep8style.ignore_code('F')) + self.assertFalse(pep8style.ignore_code('F401')) + self.assertTrue(pep8style.ignore_code('F402')) + def test_styleguide_excluded(self): pep8style = pep8.StyleGuide(paths=[E11]) @@ -292,5 +309,30 @@ class APITestCase(unittest.TestCase): self.assertRaises(TypeError, pep8style.check_files, 42) # < 3.3 raises TypeError; >= 3.3 raises AttributeError self.assertRaises(Exception, pep8style.check_files, [42]) + + def test_check_unicode(self): + # Do not crash if lines are Unicode (Python 2.x) + pep8.register_check(DummyChecker, ['Z701']) + source = '#\n' + if hasattr(source, 'decode'): + source = source.decode('ascii') + + pep8style = pep8.StyleGuide() + count_errors = pep8style.input_file('stdin', lines=[source]) + + self.assertFalse(sys.stdout) + self.assertFalse(sys.stderr) + self.assertEqual(count_errors, 0) + + def test_check_nullbytes(self): + pep8.register_check(DummyChecker, ['Z701']) + + pep8style = pep8.StyleGuide() + count_errors = pep8style.input_file('stdin', lines=['\x00\n']) + + self.assertTrue(sys.stdout[0].startswith("stdin:1:1: E901 TypeError")) + self.assertFalse(sys.stderr) + self.assertEqual(count_errors, 1) + # TODO: runner # TODO: input_file diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py index 4317bca..1f12b44 100644 --- a/testsuite/test_shell.py +++ b/testsuite/test_shell.py @@ -15,14 +15,17 @@ class ShellTestCase(unittest.TestCase): self._saved_stdout = sys.stdout self._saved_stderr = sys.stderr self._saved_pconfig = pep8.PROJECT_CONFIG - self._saved_cpread = pep8.RawConfigParser.read + self._saved_cpread = pep8.RawConfigParser._read self._saved_stdin_get_value = pep8.stdin_get_value self._config_filenames = [] self.stdin = '' sys.argv = ['pep8'] sys.stdout = PseudoFile() sys.stderr = PseudoFile() - pep8.RawConfigParser.read = self._config_filenames.append + + def fake_config_parser_read(cp, fp, filename): + self._config_filenames.append(filename) + pep8.RawConfigParser._read = fake_config_parser_read pep8.stdin_get_value = self.stdin_get_value def tearDown(self): @@ -30,7 +33,7 @@ class ShellTestCase(unittest.TestCase): sys.stdout = self._saved_stdout sys.stderr = self._saved_stderr pep8.PROJECT_CONFIG = self._saved_pconfig - pep8.RawConfigParser.read = self._saved_cpread + pep8.RawConfigParser._read = self._saved_cpread pep8.stdin_get_value = self._saved_stdin_get_value def stdin_get_value(self): diff --git a/testsuite/utf-8-bom.py b/testsuite/utf-8-bom.py new file mode 100644 index 0000000..9c065c9 --- /dev/null +++ b/testsuite/utf-8-bom.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +hello = 'こんにちわ' + +# EOF |