Skip to content

Commit

Permalink
Test behaviour regarding multi-line ignore parsing in config_file
Browse files Browse the repository at this point in the history
At time of writing, these tests fail. If this is later fixed, someone
may wish to remove this warning!
  • Loading branch information
doismellburning committed Aug 22, 2015
1 parent 151758c commit 8aac6b5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
3 changes: 2 additions & 1 deletion testsuite/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ def test_own_dog_food(self):


def suite():
from testsuite import test_api, test_shell, test_util
from testsuite import test_api, test_parser, test_shell, test_util

suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Pep8TestCase))
suite.addTest(unittest.makeSuite(test_api.APITestCase))
suite.addTest(unittest.makeSuite(test_parser.ParserTestCase))
suite.addTest(unittest.makeSuite(test_shell.ShellTestCase))
suite.addTest(unittest.makeSuite(test_util.UtilTestCase))
return suite
Expand Down
61 changes: 61 additions & 0 deletions testsuite/test_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import tempfile
import unittest

import pep8


def _process_file(contents):
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(contents)

options, args = pep8.process_options(config_file=f.name)
os.remove(f.name)

return options, args


class ParserTestCase(unittest.TestCase):

def test_vanilla_ignore_parsing(self):
contents = b"""
[pep8]
ignore = E226,E24
"""
options, args = _process_file(contents)

self.assertEqual(options.ignore, ["E226", "E24"])

def test_multiline_ignore_parsing(self):
contents = b"""
[pep8]
ignore =
E226,
E24
"""

options, args = _process_file(contents)

self.assertEqual(options.ignore, ["E226", "E24"])

def test_trailing_comma_ignore_parsing(self):
contents = b"""
[pep8]
ignore = E226,
"""

options, args = _process_file(contents)

self.assertEqual(options.ignore, ["E226"])

def test_multiline_trailing_comma_ignore_parsing(self):
contents = b"""
[pep8]
ignore =
E226,
E24,
"""

options, args = _process_file(contents)

self.assertEqual(options.ignore, ["E226", "E24"])

0 comments on commit 8aac6b5

Please sign in to comment.