[Python-checkins] bpo-40723: Make IDLE autocomplete test run without __main__.__file__ (GH-20311)

Miss Islington (bot) webhook-mailer at python.org
Sun May 24 07:12:16 EDT 2020


https://github.com/python/cpython/commit/82397e2d97f89fdf36cb8eaf3b2d7c407456ec78
commit: 82397e2d97f89fdf36cb8eaf3b2d7c407456ec78
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-05-24T04:12:11-07:00
summary:

bpo-40723: Make IDLE autocomplete test run without __main__.__file__ (GH-20311)


This was the only failure running unittest.main(test.test_idle) after imports.
(cherry picked from commit 905b3cd05f8d2c29e1605d109900e3e9d07af4d3)

Co-authored-by: Florian Dahlitz <f2dahlitz at freenet.de>

files:
A Misc/NEWS.d/next/IDLE/2020-05-24-06-19-43.bpo-40723.AJLd4U.rst
M Lib/idlelib/NEWS.txt
M Lib/idlelib/idle_test/test_autocomplete.py

diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 93084bfc2e554..7d77f6cf4529e 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,8 @@ Released on 2019-12-16?
 ======================================
 
 
+bpo-40723: Make test_idle pass when run after import.
+
 bpo-38689: IDLE will no longer freeze when inspect.signature fails
 when fetching a calltip.
 
diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py
index 2c478cd5c2a14..1841495fcf1a0 100644
--- a/Lib/idlelib/idle_test/test_autocomplete.py
+++ b/Lib/idlelib/idle_test/test_autocomplete.py
@@ -227,7 +227,7 @@ def test_fetch_completions(self):
         acp = self.autocomplete
         small, large = acp.fetch_completions(
                 '', ac.ATTRS)
-        if __main__.__file__ != ac.__file__:
+        if hasattr(__main__, '__file__') and __main__.__file__ != ac.__file__:
             self.assertNotIn('AutoComplete', small)  # See issue 36405.
 
         # Test attributes
diff --git a/Misc/NEWS.d/next/IDLE/2020-05-24-06-19-43.bpo-40723.AJLd4U.rst b/Misc/NEWS.d/next/IDLE/2020-05-24-06-19-43.bpo-40723.AJLd4U.rst
new file mode 100644
index 0000000000000..e0de2f9d83668
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2020-05-24-06-19-43.bpo-40723.AJLd4U.rst
@@ -0,0 +1 @@
+Make test_idle pass when run after import.



More information about the Python-checkins mailing list