-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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!
- Loading branch information
1 parent
151758c
commit 71198d3
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = """ | ||
[pep8] | ||
ignore = E226,E24 | ||
""" | ||
options, args = _process_file(contents) | ||
|
||
self.assertEqual(options.ignore, ["E226", "E24"]) | ||
|
||
def test_multiline_ignore_parsing(self): | ||
contents = """ | ||
[pep8] | ||
ignore = | ||
E226, | ||
E24 | ||
""" | ||
|
||
options, args = _process_file(contents) | ||
|
||
self.assertEqual(options.ignore, ["E226", "E24"]) | ||
|
||
def test_trailing_comma_ignore_parsing(self): | ||
contents = """ | ||
[pep8] | ||
ignore = E226, | ||
""" | ||
|
||
options, args = _process_file(contents) | ||
|
||
self.assertEqual(options.ignore, ["E226"]) | ||
|
||
def test_multiline_trailing_comma_ignore_parsing(self): | ||
contents = """ | ||
[pep8] | ||
ignore = | ||
E226, | ||
E24, | ||
""" | ||
|
||
options, args = _process_file(contents) | ||
|
||
self.assertEqual(options.ignore, ["E226", "E24"]) |