[Python-checkins] cpython (merge 3.6 -> default): Issue #28192: Adds tests for hook in isolated mode

steve.dower python-checkins at python.org
Sat Sep 17 17:35:55 EDT 2016


https://hg.python.org/cpython/rev/6c7a8a012669
changeset:   103896:6c7a8a012669
parent:      103894:187a114b9ef4
parent:      103895:5761294bb877
user:        Steve Dower <steve.dower at microsoft.com>
date:        Sat Sep 17 14:35:43 2016 -0700
summary:
  Issue #28192: Adds tests for hook in isolated mode

files:
  Lib/test/test_site.py |  18 ++++++++++++++++++
  1 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -471,5 +471,23 @@
         if sys.platform != 'darwin':
             self.assertFalse(modules.intersection(collection_mods), stderr)
 
+    def test_startup_interactivehook(self):
+        r = subprocess.Popen([sys.executable, '-c',
+            'import sys; sys.exit(hasattr(sys, "__interactivehook__"))']).wait()
+        self.assertTrue(r, "'__interactivehook__' not added by site")
+
+    def test_startup_interactivehook_isolated(self):
+        # issue28192 readline is not automatically enabled in isolated mode
+        r = subprocess.Popen([sys.executable, '-I', '-c',
+            'import sys; sys.exit(hasattr(sys, "__interactivehook__"))']).wait()
+        self.assertFalse(r, "'__interactivehook__' added in isolated mode")
+
+    def test_startup_interactivehook_isolated_explicit(self):
+        # issue28192 readline can be explicitly enabled in isolated mode
+        r = subprocess.Popen([sys.executable, '-I', '-c',
+            'import site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))']).wait()
+        self.assertTrue(r, "'__interactivehook__' not added by enablerlcompleter()")
+
+
 if __name__ == "__main__":
     unittest.main()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list