summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorKristian Glass <git@doismellburning.co.uk>2015-08-22 11:32:27 +0100
committerKristian Glass <git@doismellburning.co.uk>2015-08-22 11:53:54 +0100
commit8aac6b5cc3fc2fba33c5a9108feae97e7907ce9b (patch)
treec9d51784d3b545301d682c6759a8719ec72bec4b /testsuite
parent151758ce8f29fd65e10dc0720446c5a3bb164602 (diff)
downloadpep8-8aac6b5cc3fc2fba33c5a9108feae97e7907ce9b.tar.gz
Test behaviour regarding multi-line ignore parsing in config_file
At time of writing, these tests fail. If this is later fixed, someone may wish to remove this warning!
Diffstat (limited to 'testsuite')
-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"])