File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed
Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,12 @@ def test_own_dog_food(self):
4646
4747
4848def suite ():
49- from testsuite import test_api , test_shell , test_util
49+ from testsuite import test_api , test_parser , test_shell , test_util
5050
5151 suite = unittest .TestSuite ()
5252 suite .addTest (unittest .makeSuite (Pep8TestCase ))
5353 suite .addTest (unittest .makeSuite (test_api .APITestCase ))
54+ suite .addTest (unittest .makeSuite (test_parser .ParserTestCase ))
5455 suite .addTest (unittest .makeSuite (test_shell .ShellTestCase ))
5556 suite .addTest (unittest .makeSuite (test_util .UtilTestCase ))
5657 return suite
Original file line number Diff line number Diff line change 1+ import os
2+ import tempfile
3+ import unittest
4+
5+ import pep8
6+
7+
8+ def _process_file (contents ):
9+ with tempfile .NamedTemporaryFile (delete = False ) as f :
10+ f .write (contents )
11+
12+ options , args = pep8 .process_options (config_file = f .name )
13+ os .remove (f .name )
14+
15+ return options , args
16+
17+
18+ class ParserTestCase (unittest .TestCase ):
19+
20+ def test_vanilla_ignore_parsing (self ):
21+ contents = b"""
22+ [pep8]
23+ ignore = E226,E24
24+ """
25+ options , args = _process_file (contents )
26+
27+ self .assertEqual (options .ignore , ["E226" , "E24" ])
28+
29+ def test_multiline_ignore_parsing (self ):
30+ contents = b"""
31+ [pep8]
32+ ignore =
33+ E226,
34+ E24
35+ """
36+
37+ options , args = _process_file (contents )
38+
39+ self .assertEqual (options .ignore , ["E226" , "E24" ])
40+
41+ def test_trailing_comma_ignore_parsing (self ):
42+ contents = b"""
43+ [pep8]
44+ ignore = E226,
45+ """
46+
47+ options , args = _process_file (contents )
48+
49+ self .assertEqual (options .ignore , ["E226" ])
50+
51+ def test_multiline_trailing_comma_ignore_parsing (self ):
52+ contents = b"""
53+ [pep8]
54+ ignore =
55+ E226,
56+ E24,
57+ """
58+
59+ options , args = _process_file (contents )
60+
61+ self .assertEqual (options .ignore , ["E226" , "E24" ])
You can’t perform that action at this time.
0 commit comments