[Python-checkins] [3.9] bpo-41970: Avoid test failure in test_lib2to3 if the module is already imported (GH-22595) (GH-22609)

Karthikeyan Singaravelan webhook-mailer at python.org
Fri Oct 9 06:08:50 EDT 2020


https://github.com/python/cpython/commit/c6f41e62f55933f9735e9b9c103c6860685b028a
commit: c6f41e62f55933f9735e9b9c103c6860685b028a
branch: 3.9
author: Karthikeyan Singaravelan <tir.karthi at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-10-09T11:08:42+01:00
summary:

[3.9] bpo-41970: Avoid test failure in test_lib2to3 if the module is already imported (GH-22595) (GH-22609)

(cherry picked from commit 4a9f82f50d957b6cf3fd207de8b583d9137316b8)

Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>

files:
A Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst
M Lib/test/test_lib2to3.py

diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 15c317e957bc0..e939d47336e36 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,8 +1,8 @@
 import unittest
-from test.support import check_warnings
+from test.support import check_warnings, import_fresh_module
 
 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 0000000000000..4cdca197fbfc6
--- /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.



More information about the Python-checkins mailing list