Merge "hacking: Stop special casing 'plugins.xenserver'"

This commit is contained in:
Zuul 2020-09-10 12:19:19 +00:00 committed by Gerrit Code Review
commit 15079cfafe
2 changed files with 14 additions and 17 deletions

View File

@ -362,12 +362,6 @@ def check_explicit_underscore_import(logical_line, filename):
@core.flake8ext
def use_jsonutils(logical_line, filename):
# the code below that path is not meant to be executed from neutron
# tree where jsonutils module is present, so don't enforce its usage
# for this subdirectory
if "plugins/xenserver" in filename:
return
# tools are OK to use the standard json module
if "/tools/" in filename:
return

View File

@ -246,17 +246,20 @@ class HackingTestCase(test.NoDBTestCase):
for method in ('dump', 'dumps', 'load', 'loads'):
self.assertEqual(
__get_msg(method),
list(checks.use_jsonutils("json.%s(" % method,
"./nova/virt/xenapi/driver.py")))
self.assertEqual(0,
len(list(checks.use_jsonutils("json.%s(" % method,
"./plugins/xenserver/script.py"))))
self.assertEqual(0,
len(list(checks.use_jsonutils("jsonx.%s(" % method,
"./nova/virt/xenapi/driver.py"))))
self.assertEqual(0,
len(list(checks.use_jsonutils("json.dumb",
"./nova/virt/xenapi/driver.py"))))
list(checks.use_jsonutils(
"json.%s(" % method, "./nova/virt/libvirt/driver.py")),
)
self.assertEqual(
0,
len(list(checks.use_jsonutils(
"jsonx.%s(" % method, "./nova/virt/libvirt/driver.py"))),
)
self.assertEqual(
0,
len(list(checks.use_jsonutils(
"json.dumb", "./nova/virt/libvirt/driver.py"))),
)
# We are patching pycodestyle so that only the check under test is actually
# installed.