diff options
author | Matt Clay <matt@mystile.com> | 2018-09-14 11:12:06 -0700 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2019-01-09 21:48:12 -0800 |
commit | 100e4639aa78057a1b16d322e304f9cb46ebd4a4 (patch) | |
tree | f025a31eda5d1afa134095a1391ba4bd0a5b2e95 | |
parent | 5fa8d5448899cb42c49ec9fcab1aefa9c6c52bba (diff) | |
download | ansible-100e4639aa78057a1b16d322e304f9cb46ebd4a4.tar.gz |
[stable-2.7] Minor cleanup of code-smell tests. (#45658)
* Minor cleanup of code-smell tests.
* Add exception handling for YAML load..
(cherry picked from commit e7426e379575811714e062990ea42a20c79633a4)
Co-authored-by: Matt Clay <matt@mystile.com>
-rwxr-xr-x | test/sanity/code-smell/no-illegal-filenames.py | 8 | ||||
-rwxr-xr-x | test/sanity/code-smell/no-tests-as-filters.py | 2 | ||||
-rwxr-xr-x | test/sanity/code-smell/no-underscore-variable.py | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/test/sanity/code-smell/no-illegal-filenames.py b/test/sanity/code-smell/no-illegal-filenames.py index 52959d3e17..1a663c5aa7 100755 --- a/test/sanity/code-smell/no-illegal-filenames.py +++ b/test/sanity/code-smell/no-illegal-filenames.py @@ -53,8 +53,8 @@ ILLEGAL_END_CHARS = [ ] -def check_path(path, dir=False): - type_name = 'directory' if dir else 'file' +def check_path(path, is_dir=False): + type_name = 'directory' if is_dir else 'file' parent, file_name = os.path.split(path) name, ext = os.path.splitext(file_name) @@ -85,10 +85,10 @@ def main(): continue for dir_name in dirs: - check_path(os.path.join(root, dir_name), dir=True) + check_path(os.path.join(root, dir_name), is_dir=True) for file_name in files: - check_path(os.path.join(root, file_name), dir=False) + check_path(os.path.join(root, file_name), is_dir=False) if __name__ == '__main__': diff --git a/test/sanity/code-smell/no-tests-as-filters.py b/test/sanity/code-smell/no-tests-as-filters.py index 18581bdc20..792dc98834 100755 --- a/test/sanity/code-smell/no-tests-as-filters.py +++ b/test/sanity/code-smell/no-tests-as-filters.py @@ -45,7 +45,7 @@ TEST_MAP = { } -FILTER_RE = re.compile(r'((.+?)\s*(?P<left>[\w \.\'"]+)(\s*)\|(\s*)(?P<filter>\w+))') +FILTER_RE = re.compile(r'((.+?)\s*(?P<left>[\w .\'"]+)(\s*)\|(\s*)(?P<filter>\w+))') def main(): diff --git a/test/sanity/code-smell/no-underscore-variable.py b/test/sanity/code-smell/no-underscore-variable.py index 3ec540fe63..bba6173f7e 100755 --- a/test/sanity/code-smell/no-underscore-variable.py +++ b/test/sanity/code-smell/no-underscore-variable.py @@ -129,7 +129,7 @@ def main(): with open(path, 'r') as path_fd: for line, text in enumerate(path_fd.readlines()): - match = re.search(r'(?: |[^C]\()(_)(?: |,|\))', text) + match = re.search(r'(?: |[^C]\()(_)(?:[ ,)])', text) if match: print('%s:%d:%d: use `dummy` instead of `_` for a variable name' % ( |