diff options
author | Matt Clay <matt@mystile.com> | 2023-03-07 09:01:01 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 09:01:01 -0800 |
commit | edb7635d690ad809419c669ff454c9dc852af102 (patch) | |
tree | 36a66e8ec6bae74b6bc2e3a8bb257fa96977e6fd | |
parent | 2154de5eb5bd6af0076e0e68633a0cf3e1625d1e (diff) | |
download | ansible-edb7635d690ad809419c669ff454c9dc852af102.tar.gz |
[stable-2.12] ansible-test - Fix pylint error with old home dir (#80151) (#80154)
* [stable-2.12] ansible-test - Fix pylint error with old home dir (#80151)
(cherry picked from commit 27287b40c0605e583145538ac072260095c139d7)
Co-authored-by: Matt Clay <matt@mystile.com>
* ansible-test - Fix error with missing pylint home (#80155)
(cherry picked from commit 367d45facd3af9bbc8159e4371d94e95629bed6d)
-rw-r--r-- | changelogs/fragments/ansible-test-pylint-home.yml | 2 | ||||
-rw-r--r-- | test/lib/ansible_test/_internal/commands/sanity/pylint.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/changelogs/fragments/ansible-test-pylint-home.yml b/changelogs/fragments/ansible-test-pylint-home.yml new file mode 100644 index 0000000000..dcd3dfc87b --- /dev/null +++ b/changelogs/fragments/ansible-test-pylint-home.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test - Set ``PYLINTHOME`` for the ``pylint`` sanity test to prevent failures due to ``pylint`` checking for the existence of an obsolete home directory. diff --git a/test/lib/ansible_test/_internal/commands/sanity/pylint.py b/test/lib/ansible_test/_internal/commands/sanity/pylint.py index eafc5d5e0b..f5061fec76 100644 --- a/test/lib/ansible_test/_internal/commands/sanity/pylint.py +++ b/test/lib/ansible_test/_internal/commands/sanity/pylint.py @@ -17,6 +17,10 @@ from . import ( SANITY_ROOT, ) +from ...io import ( + make_dirs, +) + from ...test import ( TestResult, ) @@ -40,6 +44,7 @@ from ...ansible_util import ( get_collection_detail, CollectionDetail, CollectionDetailError, + ResultType, ) from ...config import ( @@ -246,6 +251,12 @@ class PylintTest(SanitySingleVersion): # expose plugin paths for use in custom plugins env.update(dict(('ANSIBLE_TEST_%s_PATH' % k.upper(), os.path.abspath(v) + os.path.sep) for k, v in data_context().content.plugin_paths.items())) + # Set PYLINTHOME to prevent pylint from checking for an obsolete directory, which can result in a test failure due to stderr output. + # See: https://github.com/PyCQA/pylint/blob/e6c6bf5dfd61511d64779f54264b27a368c43100/pylint/constants.py#L148 + pylint_home = os.path.join(ResultType.TMP.path, 'pylint') + make_dirs(pylint_home) + env.update(PYLINTHOME=pylint_home) + if paths: display.info('Checking %d file(s) in context "%s" with config: %s' % (len(paths), context, rcfile), verbosity=1) |