Merge "Fix N332 api_version decorator hacking check"
This commit is contained in:
@@ -85,7 +85,7 @@ import_translation_for_log_or_exception = re.compile(
|
||||
r"(.)*(from\snova.i18n\simport)\s_")
|
||||
# We need this for cases where they have created their own _ function.
|
||||
custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*")
|
||||
api_version_re = re.compile(r"@.*api_version")
|
||||
api_version_re = re.compile(r"@.*\bapi_version\b")
|
||||
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
|
||||
decorator_re = re.compile(r"@.*")
|
||||
http_not_implemented_re = re.compile(r"raise .*HTTPNotImplemented\(")
|
||||
|
||||
@@ -381,13 +381,22 @@ class HackingTestCase(test.NoDBTestCase):
|
||||
expected_errors=[(1, 0, "N335")])
|
||||
|
||||
def test_api_version_decorator_check_no_errors(self):
|
||||
code = """
|
||||
class ControllerClass():
|
||||
@wsgi.api_version("2.5")
|
||||
def my_method():
|
||||
pass
|
||||
"""
|
||||
self._assert_has_no_errors(code, checks.check_api_version_decorator)
|
||||
codelist = [
|
||||
"""
|
||||
class ControllerClass():
|
||||
@wsgi.api_version("2.5")
|
||||
def my_method():
|
||||
pass
|
||||
""",
|
||||
"""
|
||||
@some_other_decorator
|
||||
@mock.patch('foo', return_value=api_versions.APIVersion("2.5"))
|
||||
def my_method():
|
||||
pass
|
||||
"""]
|
||||
for code in codelist:
|
||||
self._assert_has_no_errors(
|
||||
code, checks.check_api_version_decorator)
|
||||
|
||||
def test_trans_add(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user