summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/test_all.py3
-rw-r--r--testsuite/test_parser.py61
2 files changed, 63 insertions, 1 deletions
diff --git a/testsuite/test_all.py b/testsuite/test_all.py
index 50e2cb9..bfb61d5 100644
--- a/testsuite/test_all.py
+++ b/testsuite/test_all.py
@@ -46,11 +46,12 @@ class Pep8TestCase(unittest.TestCase):
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
diff --git a/testsuite/test_parser.py b/testsuite/test_parser.py
new file mode 100644
index 0000000..1d9e1ac
--- /dev/null
+++ b/testsuite/test_parser.py
@@ -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"])