Merge "Temporary add per-file-ignores to flake8 tests"
This commit is contained in:
commit
a97c95364f
@ -65,8 +65,8 @@ MIGRATIONS_TIMEOUT = 300
|
||||
|
||||
@contextlib.contextmanager
|
||||
def patch_with_engine(engine):
|
||||
with mock.patch.object(enginefacade.writer,
|
||||
'get_engine') as patch_engine:
|
||||
with mock.patch.object(enginefacade.writer, 'get_engine',
|
||||
autospec=True) as patch_engine:
|
||||
patch_engine.return_value = engine
|
||||
yield
|
||||
|
||||
@ -150,10 +150,10 @@ class TestWalkVersions(base.TestCase, WalkVersionsMixin):
|
||||
self._pre_upgrade_141.assert_called_with(self.engine)
|
||||
self._check_141.assert_called_with(self.engine, test_value)
|
||||
|
||||
@mock.patch.object(script, 'ScriptDirectory')
|
||||
@mock.patch.object(WalkVersionsMixin, '_migrate_up')
|
||||
@mock.patch.object(script, 'ScriptDirectory', autospec=True)
|
||||
@mock.patch.object(WalkVersionsMixin, '_migrate_up', autospec=True)
|
||||
def test_walk_versions_all_default(self, _migrate_up, script_directory):
|
||||
fc = script_directory.from_config()
|
||||
fc = script_directory.from_config.return_value
|
||||
fc.walk_revisions.return_value = self.versions
|
||||
self.migration_api.version.return_value = None
|
||||
|
||||
@ -161,20 +161,20 @@ class TestWalkVersions(base.TestCase, WalkVersionsMixin):
|
||||
|
||||
self.migration_api.version.assert_called_with(self.config)
|
||||
|
||||
upgraded = [mock.call(self.engine, self.config, v.revision,
|
||||
upgraded = [mock.call(self, self.engine, self.config, v.revision,
|
||||
with_data=True) for v in reversed(self.versions)]
|
||||
self.assertEqual(self._migrate_up.call_args_list, upgraded)
|
||||
|
||||
@mock.patch.object(script, 'ScriptDirectory')
|
||||
@mock.patch.object(WalkVersionsMixin, '_migrate_up')
|
||||
@mock.patch.object(script, 'ScriptDirectory', autospec=True)
|
||||
@mock.patch.object(WalkVersionsMixin, '_migrate_up', autospec=True)
|
||||
def test_walk_versions_all_false(self, _migrate_up, script_directory):
|
||||
fc = script_directory.from_config()
|
||||
fc = script_directory.from_config.return_value
|
||||
fc.walk_revisions.return_value = self.versions
|
||||
self.migration_api.version.return_value = None
|
||||
|
||||
self._walk_versions(self.engine, self.config)
|
||||
|
||||
upgraded = [mock.call(self.engine, self.config, v.revision,
|
||||
upgraded = [mock.call(self, self.engine, self.config, v.revision,
|
||||
with_data=True) for v in reversed(self.versions)]
|
||||
self.assertEqual(upgraded, self._migrate_up.call_args_list)
|
||||
|
||||
|
@ -61,8 +61,8 @@ class TestDHCPFactory(base.TestCase):
|
||||
group='dhcp')
|
||||
dhcp_factory.DHCPFactory()
|
||||
|
||||
with mock.patch.object(dhcp_factory.DHCPFactory,
|
||||
'_set_dhcp_provider') as mock_set_dhcp:
|
||||
with mock.patch.object(dhcp_factory.DHCPFactory, '_set_dhcp_provider',
|
||||
autospec=True) as mock_set_dhcp:
|
||||
# There is already a dhcp_provider, so this shouldn't call
|
||||
# _set_dhcp_provider again.
|
||||
dhcp_factory.DHCPFactory()
|
||||
|
@ -8,6 +8,7 @@ ddt==1.0.1
|
||||
doc8==0.6.0
|
||||
eventlet==0.18.2
|
||||
fixtures==3.0.0
|
||||
flake8==3.7.0
|
||||
flake8-import-order==0.17.1
|
||||
futurist==1.2.0
|
||||
hacking==3.0.0
|
||||
|
@ -15,6 +15,7 @@ psycopg2>=2.7.3 # LGPL/ZPL
|
||||
testtools>=2.2.0 # MIT
|
||||
WebTest>=2.0.27 # MIT
|
||||
bashate>=0.5.1 # Apache-2.0
|
||||
flake8>=3.7.0 # MIT
|
||||
flake8-import-order>=0.17.1 # LGPLv3
|
||||
Pygments>=2.2.0 # BSD
|
||||
bandit!=1.6.0,>=1.1.0,<2.0.0 # Apache-2.0
|
||||
|
12
tox.ini
12
tox.ini
@ -120,9 +120,17 @@ max-complexity=18
|
||||
# [H203] Use assertIs(Not)None to check for None.
|
||||
# [H204] Use assert(Not)Equal to check for equality.
|
||||
# [H205] Use assert(Greater|Less)(Equal) for comparison.
|
||||
# TODO(dtantsur): [H210] Require ‘autospec’, ‘spec’, or ‘spec_set’ in mock.patch/mock.patch.object calls
|
||||
# [H210] Require ‘autospec’, ‘spec’, or ‘spec_set’ in mock.patch/mock.patch.object calls
|
||||
# [H904] Delay string interpolations at logging calls.
|
||||
enable-extensions=H106,H203,H204,H205,H904
|
||||
enable-extensions=H106,H203,H204,H205,H210,H904
|
||||
# TODO(rpittau) remove the ignores below when we're ready to apply H210 to
|
||||
# the various modules. This can be done in batches changing the filters.
|
||||
per-file-ignores =
|
||||
ironic/tests/unit/api/*:H210
|
||||
ironic/tests/unit/conductor/*:H210
|
||||
ironic/tests/unit/common/*:H210
|
||||
ironic/tests/unit/drivers/modules/*:H210
|
||||
ironic/tests/unit/drivers/third_party_driver_mocks.py:H210
|
||||
|
||||
[hacking]
|
||||
import_exceptions = testtools.matchers, ironic.common.i18n
|
||||
|
Loading…
Reference in New Issue
Block a user