From 4a9f82f50d957b6cf3fd207de8b583d9137316b8 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Thu, 8 Oct 2020 14:24:28 +0100 Subject: [PATCH] bpo-41970: Avoid test failure in test_lib2to3 if the module is already imported (GH-22595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … Automerge-Triggered-By: @pablogsal --- Lib/test/test_lib2to3.py | 3 ++- .../NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py index 159a8387e4e..fd12a7e7acb 100644 --- a/Lib/test/test_lib2to3.py +++ b/Lib/test/test_lib2to3.py @@ -1,8 +1,9 @@ import unittest +from test.support.import_helper import import_fresh_module from test.support.warnings_helper import check_warnings with check_warnings(("", PendingDeprecationWarning)): - from lib2to3.tests import load_tests + load_tests = import_fresh_module('lib2to3.tests', fresh=['lib2to3']).load_tests if __name__ == '__main__': unittest.main() diff --git a/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst b/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst new file mode 100644 index 00000000000..4cdca197fbf --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst @@ -0,0 +1,2 @@ +Avoid a test failure in ``test_lib2to3`` if the module has already imported +at the time the test executes. Patch by Pablo Galindo.