mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Add better logic for loading entry points
As noted in the code, setuptools 11.3 deprecated EntryPoint.load and its require parameter. Starting with 11.3 the preferred way is use EntryPoint.require and EntryPoint.resolve as necessary. Unfortunately, those methods do not exist in all versions of setuptools. So we have to check for them and use them when they're available. Otherwise, we fallback to using EntryPoint.load with the require parameter. Closes #59 Closes #90
This commit is contained in:
parent
b8457ebb24
commit
0c0eadc0a0
2 changed files with 45 additions and 1 deletions
|
|
@ -113,6 +113,30 @@ class TestEngine(unittest.TestCase):
|
|||
sg = engine.StyleGuide(parser=parser)
|
||||
assert 'X' not in sg.options.ignore
|
||||
|
||||
def test_load_entry_point_verifies_requirements(self):
|
||||
entry_point = mock.Mock(spec=['require', 'resolve', 'load'])
|
||||
|
||||
engine._load_entry_point(entry_point, verify_requirements=True)
|
||||
entry_point.require.assert_called_once_with()
|
||||
entry_point.resolve.assert_called_once_with()
|
||||
|
||||
def test_load_entry_point_does_not_verify_requirements(self):
|
||||
entry_point = mock.Mock(spec=['require', 'resolve', 'load'])
|
||||
|
||||
engine._load_entry_point(entry_point, verify_requirements=False)
|
||||
self.assertFalse(entry_point.require.called)
|
||||
entry_point.resolve.assert_called_once_with()
|
||||
|
||||
def test_load_entry_point_passes_require_argument_to_load(self):
|
||||
entry_point = mock.Mock(spec=['load'])
|
||||
|
||||
engine._load_entry_point(entry_point, verify_requirements=True)
|
||||
entry_point.load.assert_called_once_with(require=True)
|
||||
entry_point.reset_mock()
|
||||
|
||||
engine._load_entry_point(entry_point, verify_requirements=False)
|
||||
entry_point.load.assert_called_once_with(require=False)
|
||||
|
||||
|
||||
def oserror_generator(error_number, message='Ominous OSError message'):
|
||||
def oserror_side_effect(*args, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue