From b2fdd39572cea320524cdb429ec95e36d717c809 Mon Sep 17 00:00:00 2001 From: ZhiQiang Fan Date: Thu, 13 Nov 2014 09:29:54 +0800 Subject: [PATCH] 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 --- keystoneclient/tests/test_shell.py | 11 +++++------ tox.ini | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/keystoneclient/tests/test_shell.py b/keystoneclient/tests/test_shell.py index 4be563b02..65cba9dbd 100644 --- a/keystoneclient/tests/test_shell.py +++ b/keystoneclient/tests/test_shell.py @@ -37,6 +37,11 @@ DEFAULT_TENANT_NAME = 'tenant_name' 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): def error(self, message): raise exceptions.CommandError(message) @@ -68,12 +73,6 @@ class ShellTest(utils.TestCase): self.useFixture(fixtures.EnvironmentVariable(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): self.assertRaises(exceptions.CommandError, shell, 'help %s' % uuid.uuid4().hex) diff --git a/tox.ini b/tox.ini index b3e1d5d25..49586a554 100644 --- a/tox.ini +++ b/tox.ini @@ -31,12 +31,11 @@ downloadcache = ~/cache/pip commands = oslo_debug_helper -t keystoneclient/tests {posargs} [flake8] -# F821: undefined name # H304: no relative imports # H405: multi line docstring summary not separated with an empty line # E122: continuation line missing indentation or outdented # New from hacking 0.10: H238 -ignore = F821,H238,H304,H405,E122 +ignore = H238,H304,H405,E122 show-source = True exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*