summaryrefslogtreecommitdiffstats
path: root/test/sanity
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanity')
-rw-r--r--test/sanity/code-smell/ansible-test-future-boilerplate.json10
-rw-r--r--test/sanity/code-smell/boilerplate.json6
-rw-r--r--test/sanity/code-smell/boilerplate.py (renamed from test/sanity/code-smell/ansible-test-future-boilerplate.py)13
-rw-r--r--test/sanity/code-smell/deprecated-config.py3
-rw-r--r--test/sanity/code-smell/deprecated-config.requirements.txt4
-rw-r--r--test/sanity/code-smell/no-unwanted-characters.json4
-rw-r--r--test/sanity/code-smell/no-unwanted-characters.py27
-rw-r--r--test/sanity/code-smell/package-data.requirements.txt14
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.txt10
-rw-r--r--test/sanity/code-smell/test-constraints.py7
-rw-r--r--test/sanity/code-smell/update-bundled.py1
-rw-r--r--test/sanity/code-smell/update-bundled.requirements.txt2
-rw-r--r--test/sanity/ignore.txt30
13 files changed, 69 insertions, 62 deletions
diff --git a/test/sanity/code-smell/ansible-test-future-boilerplate.json b/test/sanity/code-smell/ansible-test-future-boilerplate.json
deleted file mode 100644
index ca4c067..0000000
--- a/test/sanity/code-smell/ansible-test-future-boilerplate.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "prefixes": [
- "test/sanity/",
- "test/lib/ansible_test/"
- ],
- "output": "path-message"
-}
diff --git a/test/sanity/code-smell/boilerplate.json b/test/sanity/code-smell/boilerplate.json
new file mode 100644
index 0000000..6f1edb7
--- /dev/null
+++ b/test/sanity/code-smell/boilerplate.json
@@ -0,0 +1,6 @@
+{
+ "extensions": [
+ ".py"
+ ],
+ "output": "path-message"
+}
diff --git a/test/sanity/code-smell/ansible-test-future-boilerplate.py b/test/sanity/code-smell/boilerplate.py
index 9a62225..d0ab20d 100644
--- a/test/sanity/code-smell/ansible-test-future-boilerplate.py
+++ b/test/sanity/code-smell/boilerplate.py
@@ -5,15 +5,7 @@ import sys
def main():
- # The following directories contain code which must work under Python 2.x.
- py2_compat = (
- 'test/lib/ansible_test/_util/target/',
- )
-
for path in sys.argv[1:] or sys.stdin.read().splitlines():
- if any(path.startswith(prefix) for prefix in py2_compat):
- continue
-
with open(path, 'rb') as path_fd:
lines = path_fd.read().splitlines()
@@ -25,11 +17,11 @@ def main():
invalid_future = []
for text in lines:
- if text == b'from __future__ import annotations':
+ if text in (b'from __future__ import annotations', b'from __future__ import annotations # pragma: nocover'):
missing = False
break
- if text.startswith(b'from __future__ ') or text == b'__metaclass__ = type':
+ if text.strip().startswith(b'from __future__ ') or text.strip().startswith(b'__metaclass__ '):
invalid_future.append(text.decode())
if missing:
@@ -41,7 +33,6 @@ def main():
node = ast.parse(contents)
# files consisting of only assignments have no need for future import boilerplate
- # the only exception would be division during assignment, but we'll overlook that for simplicity
# the most likely case is that of a documentation only python file
if all(isinstance(statement, ast.Assign) for statement in node.body):
missing = False
diff --git a/test/sanity/code-smell/deprecated-config.py b/test/sanity/code-smell/deprecated-config.py
index 474628a..7056ca2 100644
--- a/test/sanity/code-smell/deprecated-config.py
+++ b/test/sanity/code-smell/deprecated-config.py
@@ -55,8 +55,7 @@ def find_deprecations(obj, path=None):
this_path.append(key)
if key != 'deprecated':
- for result in find_deprecations(value, path=this_path):
- yield result
+ yield from find_deprecations(value, path=this_path)
else:
try:
version = value['version']
diff --git a/test/sanity/code-smell/deprecated-config.requirements.txt b/test/sanity/code-smell/deprecated-config.requirements.txt
index ae96cdf..42c1825 100644
--- a/test/sanity/code-smell/deprecated-config.requirements.txt
+++ b/test/sanity/code-smell/deprecated-config.requirements.txt
@@ -1,4 +1,4 @@
# edit "deprecated-config.requirements.in" and generate with: hacking/update-sanity-requirements.py --test deprecated-config
-Jinja2==3.1.2
-MarkupSafe==2.1.3
+Jinja2==3.1.3
+MarkupSafe==2.1.5
PyYAML==6.0.1
diff --git a/test/sanity/code-smell/no-unwanted-characters.json b/test/sanity/code-smell/no-unwanted-characters.json
new file mode 100644
index 0000000..5648429
--- /dev/null
+++ b/test/sanity/code-smell/no-unwanted-characters.json
@@ -0,0 +1,4 @@
+{
+ "text": true,
+ "output": "path-line-column-message"
+}
diff --git a/test/sanity/code-smell/no-unwanted-characters.py b/test/sanity/code-smell/no-unwanted-characters.py
new file mode 100644
index 0000000..26e5912
--- /dev/null
+++ b/test/sanity/code-smell/no-unwanted-characters.py
@@ -0,0 +1,27 @@
+"""Disallow use of unwanted Unicode characters."""
+from __future__ import annotations
+
+import re
+import sys
+
+
+def main():
+ """Main entry point."""
+ for path in sys.argv[1:] or sys.stdin.read().splitlines():
+ with open(path, 'rb') as path_fd:
+ for line, text in enumerate(path_fd.readlines()):
+ try:
+ text = text.decode('utf-8')
+ except UnicodeDecodeError as ex:
+ print('%s:%d:%d: UnicodeDecodeError: %s' % (path, line + 1, ex.start + 1, ex))
+ continue
+
+ match = re.search('(\u00a0)', text)
+
+ if match:
+ print('%s:%d:%d: use an ASCII space instead of a Unicode no-break space' % (
+ path, line + 1, match.start(1) + 1))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/sanity/code-smell/package-data.requirements.txt b/test/sanity/code-smell/package-data.requirements.txt
index ce0fb9c..4faee33 100644
--- a/test/sanity/code-smell/package-data.requirements.txt
+++ b/test/sanity/code-smell/package-data.requirements.txt
@@ -1,10 +1,10 @@
# edit "package-data.requirements.in" and generate with: hacking/update-sanity-requirements.py --test package-data
-antsibull-changelog==0.23.0
-build==1.0.3
+antsibull-changelog==0.26.0
+build==1.1.1
docutils==0.18.1
-Jinja2==3.1.2
-MarkupSafe==2.1.3
-packaging==23.2
+Jinja2==3.1.3
+MarkupSafe==2.1.5
+packaging==24.0
pyproject_hooks==1.0.0
PyYAML==6.0.1
resolvelib==1.0.1
@@ -13,5 +13,5 @@ semantic-version==2.10.0
setuptools==66.1.0
tomli==2.0.1
types-docutils==0.18.3
-typing_extensions==4.8.0
-wheel==0.41.2
+typing_extensions==4.10.0
+wheel==0.43.0
diff --git a/test/sanity/code-smell/pymarkdown.requirements.txt b/test/sanity/code-smell/pymarkdown.requirements.txt
index f906e14..c1571c9 100644
--- a/test/sanity/code-smell/pymarkdown.requirements.txt
+++ b/test/sanity/code-smell/pymarkdown.requirements.txt
@@ -1,9 +1,9 @@
# edit "pymarkdown.requirements.in" and generate with: hacking/update-sanity-requirements.py --test pymarkdown
-application-properties==0.8.1
+application_properties==0.8.2
Columnar==1.4.1
-pymarkdownlnt==0.9.13.4
+pymarkdownlnt==0.9.18
PyYAML==6.0.1
tomli==2.0.1
-toolz==0.12.0
-typing_extensions==4.8.0
-wcwidth==0.2.8
+toolz==0.12.1
+typing_extensions==4.10.0
+wcwidth==0.2.13
diff --git a/test/sanity/code-smell/test-constraints.py b/test/sanity/code-smell/test-constraints.py
index ac5bb4e..3802228 100644
--- a/test/sanity/code-smell/test-constraints.py
+++ b/test/sanity/code-smell/test-constraints.py
@@ -69,16 +69,13 @@ def main():
def check_ansible_test(path: str, requirements: list[tuple[int, str, re.Match]]) -> None:
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent.joinpath('lib')))
- from ansible_test._internal.python_requirements import VIRTUALENV_VERSION
from ansible_test._internal.coverage_util import COVERAGE_VERSIONS
from ansible_test._internal.util import version_to_str
- expected_lines = set([
- f"virtualenv == {VIRTUALENV_VERSION} ; python_version < '3'",
- ] + [
+ expected_lines = set((
f"coverage == {item.coverage_version} ; python_version >= '{version_to_str(item.min_python)}' and python_version <= '{version_to_str(item.max_python)}'"
for item in COVERAGE_VERSIONS
- ])
+ ))
for idx, requirement in enumerate(requirements):
lineno, line, match = requirement
diff --git a/test/sanity/code-smell/update-bundled.py b/test/sanity/code-smell/update-bundled.py
index 4bad77a..61c837c 100644
--- a/test/sanity/code-smell/update-bundled.py
+++ b/test/sanity/code-smell/update-bundled.py
@@ -49,7 +49,6 @@ def get_bundled_libs(paths):
for filename in fnmatch.filter(paths, 'lib/ansible/compat/*/__init__.py'):
bundled_libs.add(filename)
- bundled_libs.add('lib/ansible/module_utils/compat/selectors.py')
bundled_libs.add('lib/ansible/module_utils/distro/__init__.py')
bundled_libs.add('lib/ansible/module_utils/six/__init__.py')
# backports.ssl_match_hostname should be moved to its own file in the future
diff --git a/test/sanity/code-smell/update-bundled.requirements.txt b/test/sanity/code-smell/update-bundled.requirements.txt
index 53f1e43..76bf9c5 100644
--- a/test/sanity/code-smell/update-bundled.requirements.txt
+++ b/test/sanity/code-smell/update-bundled.requirements.txt
@@ -1,2 +1,2 @@
# edit "update-bundled.requirements.in" and generate with: hacking/update-sanity-requirements.py --test update-bundled
-packaging==23.2
+packaging==24.0
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index c683fbe..89fcd02 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -37,7 +37,6 @@ lib/ansible/modules/git.py use-argspec-type-path
lib/ansible/modules/git.py validate-modules:doc-required-mismatch
lib/ansible/modules/lineinfile.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/lineinfile.py validate-modules:doc-default-does-not-match-spec
-lib/ansible/modules/lineinfile.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/package_facts.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/replace.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/replace.py pylint:used-before-assignment # false positive detection by pylint
@@ -48,24 +47,17 @@ lib/ansible/modules/systemd_service.py validate-modules:parameter-invalid
lib/ansible/modules/uri.py validate-modules:doc-required-mismatch
lib/ansible/modules/user.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/user.py validate-modules:use-run-command-not-popen
-lib/ansible/modules/yum.py validate-modules:parameter-invalid
+lib/ansible/module_utils/basic.py no-get-exception # only referenced in deprecation code
lib/ansible/module_utils/basic.py pylint:unused-import # deferring resolution to allow enabling the rule now
-lib/ansible/module_utils/compat/_selectors2.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/compat/_selectors2.py metaclass-boilerplate # ignore bundled
-lib/ansible/module_utils/compat/selinux.py import-2.7!skip # pass/fail depends on presence of libselinux.so
-lib/ansible/module_utils/compat/selinux.py import-3.6!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.7!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.8!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.9!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.10!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.11!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.12!skip # pass/fail depends on presence of libselinux.so
-lib/ansible/module_utils/distro/_distro.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/distro/_distro.py metaclass-boilerplate # ignore bundled
+lib/ansible/module_utils/compat/selinux.py pylint:unidiomatic-typecheck
lib/ansible/module_utils/distro/_distro.py no-assert
lib/ansible/module_utils/distro/_distro.py pep8!skip # bundled code we don't want to modify
-lib/ansible/module_utils/distro/_distro.py pylint:undefined-variable # ignore bundled
-lib/ansible/module_utils/distro/_distro.py pylint:using-constant-test # bundled code we don't want to modify
lib/ansible/module_utils/distro/__init__.py empty-init # breaks namespacing, bundled, do not override
lib/ansible/module_utils/facts/__init__.py empty-init # breaks namespacing, deprecate and eventually remove
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 pslint:PSUseApprovedVerbs
@@ -78,14 +70,9 @@ lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 pslint:PSUse
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 pslint:PSUseApprovedVerbs
lib/ansible/module_utils/pycompat24.py no-get-exception
lib/ansible/module_utils/six/__init__.py empty-init # breaks namespacing, bundled, do not override
-lib/ansible/module_utils/six/__init__.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/six/__init__.py metaclass-boilerplate # ignore bundled
-lib/ansible/module_utils/six/__init__.py no-basestring
-lib/ansible/module_utils/six/__init__.py no-dict-iteritems
-lib/ansible/module_utils/six/__init__.py no-dict-iterkeys
-lib/ansible/module_utils/six/__init__.py no-dict-itervalues
lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable
lib/ansible/module_utils/six/__init__.py pylint:trailing-comma-tuple
+lib/ansible/module_utils/six/__init__.py pylint:unidiomatic-typecheck
lib/ansible/module_utils/six/__init__.py replace-urlopen
lib/ansible/module_utils/urls.py replace-urlopen
lib/ansible/parsing/yaml/objects.py pylint:arguments-renamed
@@ -112,6 +99,8 @@ test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/un
test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py pep8!skip # vendored code
test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py pylint:relative-beyond-top-level
test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py pylint:relative-beyond-top-level
+test/integration/targets/config/lookup_plugins/casting.py pylint:unidiomatic-typecheck
+test/integration/targets/config/lookup_plugins/casting_individual.py pylint:unidiomatic-typecheck
test/integration/targets/fork_safe_stdio/vendored_pty.py pep8!skip # vendored code
test/integration/targets/gathering_facts/library/bogus_facts shebang
test/integration/targets/gathering_facts/library/dummy1 shebang
@@ -122,16 +111,19 @@ test/integration/targets/incidental_win_reboot/templates/post_reboot.ps1 pslint!
test/integration/targets/json_cleanup/library/bad_json shebang
test/integration/targets/lookup_csvfile/files/crlf.csv line-endings
test/integration/targets/lookup_ini/lookup-8859-15.ini no-smart-quotes
+test/integration/targets/lookup_ini/lookup-8859-15.ini no-unwanted-characters
test/integration/targets/module_precedence/lib_with_extension/a.ini shebang
test/integration/targets/module_precedence/lib_with_extension/ping.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini shebang
-test/integration/targets/module_utils/library/test.py future-import-boilerplate # allow testing of Python 2.x implicit relative imports
test/integration/targets/old_style_modules_posix/library/helloworld.sh shebang
test/integration/targets/template/files/encoding_1252_utf-8.expected no-smart-quotes
+test/integration/targets/template/files/encoding_1252_utf-8.expected no-unwanted-characters
test/integration/targets/template/files/encoding_1252_windows-1252.expected no-smart-quotes
+test/integration/targets/template/files/encoding_1252_windows-1252.expected no-unwanted-characters
test/integration/targets/template/files/foo.dos.txt line-endings
test/integration/targets/template/templates/encoding_1252.j2 no-smart-quotes
+test/integration/targets/template/templates/encoding_1252.j2 no-unwanted-characters
test/integration/targets/unicode/unicode.yml no-smart-quotes
test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 pslint!skip
test/integration/targets/win_exec_wrapper/library/test_fail.ps1 pslint:PSCustomUseLiteralPath
@@ -144,7 +136,6 @@ test/integration/targets/win_script/files/test_script_removes_file.ps1 pslint:PS
test/integration/targets/win_script/files/test_script_with_args.ps1 pslint:PSAvoidUsingWriteHost # Keep
test/integration/targets/win_script/files/test_script_with_splatting.ps1 pslint:PSAvoidUsingWriteHost # Keep
test/lib/ansible_test/_data/requirements/sanity.pslint.ps1 pslint:PSCustomUseLiteralPath # Uses wildcards on purpose
-test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py no-unicode-literals
test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py pylint:arguments-renamed
test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py pylint:arguments-renamed
test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/module_utils/WebRequest.psm1 pslint!skip
@@ -179,6 +170,7 @@ test/units/utils/collection_loader/fixtures/collections_masked/ansible_collectio
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/test_collection_loader.py pylint:undefined-variable # magic runtime local var splatting
+test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py boilerplate # test requires missing boilerplate
.github/CONTRIBUTING.md pymarkdown:line-length
hacking/backport/README.md pymarkdown:no-bare-urls
hacking/ticket_stubs/bug_internal_api.md pymarkdown:no-bare-urls
@@ -202,3 +194,5 @@ README.md pymarkdown:line-length
test/integration/targets/ansible-vault/invalid_format/README.md pymarkdown:no-bare-urls
test/support/README.md pymarkdown:no-bare-urls
test/units/cli/test_data/role_skeleton/README.md pymarkdown:line-length
+test/integration/targets/find/files/hello_world.gbk no-smart-quotes
+test/integration/targets/find/files/hello_world.gbk no-unwanted-characters