]> granicus.if.org Git - python/commitdiff
Issue #28192: Adds tests for hook in isolated mode
authorSteve Dower <steve.dower@microsoft.com>
Sat, 17 Sep 2016 21:35:32 +0000 (14:35 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Sat, 17 Sep 2016 21:35:32 +0000 (14:35 -0700)
Lib/test/test_site.py

index b048648226714615b49c000acb48f0c86e00405f..d2fbb7ba2e4c3adbe0705ae7129a16e29433e87f 100644 (file)
@@ -471,5 +471,23 @@ class StartupImportTests(unittest.TestCase):
         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()