Enable hacking rule F821
F821: undefined name Currently, we define global variables at runtime in keystoneclient/tests/test_shell.py, which cannot detected by hacking rule check, then it fails for rule F821. This patch changes the global lambda shell to a helper function. Change-Id: Iaf5c4e40a6b17fbf4ba0c254b75d347f08b52364
This commit is contained in:

committed by
Jamie Lennox

parent
1b9b9ed905
commit
b2fdd39572
@@ -37,6 +37,11 @@ DEFAULT_TENANT_NAME = 'tenant_name'
|
|||||||
DEFAULT_AUTH_URL = 'http://127.0.0.1:5000/v2.0/'
|
DEFAULT_AUTH_URL = 'http://127.0.0.1:5000/v2.0/'
|
||||||
|
|
||||||
|
|
||||||
|
# Make a fake shell object, a helping wrapper to call it
|
||||||
|
def shell(cmd):
|
||||||
|
openstack_shell.OpenStackIdentityShell().main(cmd.split())
|
||||||
|
|
||||||
|
|
||||||
class NoExitArgumentParser(argparse.ArgumentParser):
|
class NoExitArgumentParser(argparse.ArgumentParser):
|
||||||
def error(self, message):
|
def error(self, message):
|
||||||
raise exceptions.CommandError(message)
|
raise exceptions.CommandError(message)
|
||||||
@@ -68,12 +73,6 @@ class ShellTest(utils.TestCase):
|
|||||||
self.useFixture(fixtures.EnvironmentVariable(var,
|
self.useFixture(fixtures.EnvironmentVariable(var,
|
||||||
self.FAKE_ENV[var]))
|
self.FAKE_ENV[var]))
|
||||||
|
|
||||||
# Make a fake shell object, a helping wrapper to call it, and a quick
|
|
||||||
# way of asserting that certain API calls were made.
|
|
||||||
global shell, _shell, assert_called, assert_called_anytime
|
|
||||||
_shell = openstack_shell.OpenStackIdentityShell()
|
|
||||||
shell = lambda cmd: _shell.main(cmd.split())
|
|
||||||
|
|
||||||
def test_help_unknown_command(self):
|
def test_help_unknown_command(self):
|
||||||
self.assertRaises(exceptions.CommandError, shell, 'help %s'
|
self.assertRaises(exceptions.CommandError, shell, 'help %s'
|
||||||
% uuid.uuid4().hex)
|
% uuid.uuid4().hex)
|
||||||
|
3
tox.ini
3
tox.ini
@@ -31,12 +31,11 @@ downloadcache = ~/cache/pip
|
|||||||
commands = oslo_debug_helper -t keystoneclient/tests {posargs}
|
commands = oslo_debug_helper -t keystoneclient/tests {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# F821: undefined name
|
|
||||||
# H304: no relative imports
|
# H304: no relative imports
|
||||||
# H405: multi line docstring summary not separated with an empty line
|
# H405: multi line docstring summary not separated with an empty line
|
||||||
# E122: continuation line missing indentation or outdented
|
# E122: continuation line missing indentation or outdented
|
||||||
# New from hacking 0.10: H238
|
# New from hacking 0.10: H238
|
||||||
ignore = F821,H238,H304,H405,E122
|
ignore = H238,H304,H405,E122
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*
|
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user