From cbac26e50035f379f7e29ea2887eb0e07b5442a7 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 6 May 2021 14:34:41 -0700 Subject: [PATCH] Update import sanity test for Python 3.10. --- .../ansible-test-sanity-import-python-3.10.yml | 2 ++ .../lib/ansible_test/_data/sanity/import/importer.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 changelogs/fragments/ansible-test-sanity-import-python-3.10.yml diff --git a/changelogs/fragments/ansible-test-sanity-import-python-3.10.yml b/changelogs/fragments/ansible-test-sanity-import-python-3.10.yml new file mode 100644 index 00000000000..8fc24e348f5 --- /dev/null +++ b/changelogs/fragments/ansible-test-sanity-import-python-3.10.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test - Update the ``import`` sanity test to avoid a new warning in Python 3.10. diff --git a/test/lib/ansible_test/_data/sanity/import/importer.py b/test/lib/ansible_test/_data/sanity/import/importer.py index f8be8e1363b..53ebce72ce0 100755 --- a/test/lib/ansible_test/_data/sanity/import/importer.py +++ b/test/lib/ansible_test/_data/sanity/import/importer.py @@ -472,6 +472,7 @@ def main(): with warnings.catch_warnings(): warnings.simplefilter('error') + if sys.version_info[0] == 2: warnings.filterwarnings( "ignore", @@ -481,6 +482,7 @@ def main(): "ignore", "Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography," " and will be removed in the next release.") + if sys.version_info[:2] == (3, 5): warnings.filterwarnings( "ignore", @@ -488,6 +490,16 @@ def main(): warnings.filterwarnings( "ignore", "Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.") + + if sys.version_info >= (3, 10): + # Temporary solution for Python 3.10 until find_spec is implemented in RestrictedModuleLoader. + # That implementation is dependent on find_spec being added to the controller's collection loader first. + # The warning text is: main..RestrictedModuleLoader.find_spec() not found; falling back to find_module() + warnings.filterwarnings( + "ignore", + r"main\.\.RestrictedModuleLoader\.find_spec\(\) not found; falling back to find_module\(\)", + ) + warnings.filterwarnings( "ignore", "The _yaml extension module is now located at yaml._yaml and its location is subject to change. To use the "