diff options
| author | Torsten Marek <shlomme@gmail.com> | 2011-09-23 17:01:32 +0200 |
|---|---|---|
| committer | Torsten Marek <shlomme@gmail.com> | 2011-09-23 17:01:32 +0200 |
| commit | 779e2c4078d5f6ee0a319a9807b215e775411426 (patch) | |
| tree | 7dc61178a94c01e978185a7d830edd01961b6d80 /test/unittest_lint.py | |
| parent | e62152e132512e83b301e955494e255f9193b1be (diff) | |
| download | pylint-git-779e2c4078d5f6ee0a319a9807b215e775411426.tar.gz | |
closes #76920: don't crash in preprocess_option if some looked option has no value
while on is expected.
Diffstat (limited to 'test/unittest_lint.py')
| -rw-r--r-- | test/unittest_lint.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/unittest_lint.py b/test/unittest_lint.py index c9f6105b8..d4bb32952 100644 --- a/test/unittest_lint.py +++ b/test/unittest_lint.py @@ -23,7 +23,8 @@ from logilab.common.testlib import TestCase, unittest_main, create_files from logilab.common.compat import reload from pylint import config -from pylint.lint import PyLinter, Run, UnknownMessage +from pylint.lint import PyLinter, Run, UnknownMessage, preprocess_options, \ + ArgumentPreprocessingError from pylint.utils import sort_msgs, PyLintASTWalker from pylint import checkers @@ -352,5 +353,31 @@ class ConfigTC(TestCase): os.chdir(HERE) rmtree(chroot) + +class PreprocessOptionsTC(TestCase): + def _callback(self, name, value): + self.args.append((name, value)) + + def test_preprocess(self): + self.args = [] + preprocess_options(['--foo', '--bar=baz', '--qu=ux'], + {'foo' : (self._callback, False), + 'qu' : (self._callback, True)}) + self.assertEqual( + [('foo', None), ('qu', 'ux')], self.args) + + def test_preprocessing_error(self): + self.assertRaises( + ArgumentPreprocessingError, + preprocess_options, + ['--foo', '--bar', '--qu=ux'], + {'bar' : (None, True)}) + self.assertRaises( + ArgumentPreprocessingError, + preprocess_options, + ['--foo', '--bar'], + {'bar' : (None, True)}) + + if __name__ == '__main__': unittest_main() |
