Add ability to turn checks off by default

This commit is contained in:
Ian Cordasco 2014-12-18 15:11:26 -06:00
parent 07677578b4
commit b301532636
2 changed files with 35 additions and 4 deletions

View file

@ -28,7 +28,7 @@ class TestEngine(unittest.TestCase):
def test_get_style_guide(self):
with mock.patch('flake8.engine._register_extensions') as reg_ext:
reg_ext.return_value = ([], [], [])
reg_ext.return_value = ([], [], [], [])
g = engine.get_style_guide()
self.assertTrue(isinstance(g, engine.StyleGuide))
reg_ext.assert_called_once_with()
@ -37,6 +37,7 @@ class TestEngine(unittest.TestCase):
m = mock.Mock()
with mock.patch('flake8.engine.StyleGuide') as StyleGuide:
with mock.patch('flake8.engine.get_parser') as get_parser:
m.ignored_extensions = []
StyleGuide.return_value.options.jobs = '42'
get_parser.return_value = (m, [])
engine.get_style_guide(foo='bar')
@ -58,7 +59,8 @@ class TestEngine(unittest.TestCase):
gpv = self.start_patch('flake8.engine.get_python_version')
pgp = self.start_patch('pep8.get_parser')
m = mock.Mock()
re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [])
re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [],
[])
gpv.return_value = 'Python Version'
pgp.return_value = m
# actual call we're testing
@ -94,5 +96,20 @@ class TestEngine(unittest.TestCase):
guide = engine.get_style_guide()
assert isinstance(guide, reporter.BaseQReport) is False
def test_disables_extensions_that_are_not_selected(self):
with mock.patch('flake8.engine._register_extensions') as re:
re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
sg = engine.get_style_guide()
assert 'X' in sg.options.ignore
def test_enables_off_by_default_extensions(self):
with mock.patch('flake8.engine._register_extensions') as re:
re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
parser, options = engine.get_parser()
parser.parse_args(['--select=X'])
sg = engine.StyleGuide(parser=parser)
assert 'X' not in sg.options.ignore
if __name__ == '__main__':
unittest.main()