[pypy-commit] pypy default: move test that used to use _ssl to _demo

mattip pypy.commits at gmail.com
Tue Oct 29 07:38:20 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r97880:037744e9abc7
Date: 2019-10-29 13:34 +0200
http://bitbucket.org/pypy/pypy/changeset/037744e9abc7/

Log:	move test that used to use _ssl to _demo

diff --git a/pypy/interpreter/test/test_appinterp.py b/pypy/interpreter/test/test_appinterp.py
--- a/pypy/interpreter/test/test_appinterp.py
+++ b/pypy/interpreter/test/test_appinterp.py
@@ -158,25 +158,3 @@
         w_str = space1.getattr(w_mymod1, space1.wrap("hi"))
         assert space1.str_w(w_str) == "hello"
 
-class TestMixedModuleUnfreeze:
-    spaceconfig = dict(usemodules=('_ssl', '_socket'))
-
-    def test_random_stuff_can_unfreeze(self):
-        # When a module contains an "import" statement in applevel code, the
-        # imported module is initialized, possibly after it has been already
-        # frozen.
-
-        # This is important when the module startup() function does something
-        # at runtime, like setting os.environ (posix module) or initializing
-        # the winsock library (_socket module)
-        w_socket = self.space.builtin_modules['_socket']
-        w_ssl = self.space.builtin_modules['_ssl']
-
-        # Uncomment this line for a workaround
-        # space.getattr(w_ssl, space.wrap('SSLError'))
-
-        w_socket._cleanup_()
-        assert w_socket.startup_called == False
-        w_ssl._cleanup_() # w_ssl.appleveldefs['SSLError'] imports _socket
-        assert w_socket.startup_called == False
-
diff --git a/pypy/module/_demo/app_demo.py b/pypy/module/_demo/app_demo.py
--- a/pypy/module/_demo/app_demo.py
+++ b/pypy/module/_demo/app_demo.py
@@ -1,3 +1,8 @@
+# import posix underneath
+from os import environ
+
+# for the test_random_stuff_can_unfreeze test
+environ['PYPY_DEMO_MODULE_ERROR'] = '1'
 
 class DemoError(Exception):
     pass
diff --git a/pypy/module/_demo/test/test_import.py b/pypy/module/_demo/test/test_import.py
--- a/pypy/module/_demo/test/test_import.py
+++ b/pypy/module/_demo/test/test_import.py
@@ -28,3 +28,23 @@
         assert Module.demo_events == ['setup', 'startup']
 
         assert space.getattr(w_demo, space.wrap('measuretime'))
+
+class TestMixedModuleUnfreeze:
+    spaceconfig = dict(usemodules=('_demo', 'posix'))
+
+    def test_random_stuff_can_unfreeze(self):
+        # When a module contains an "import" statement in applevel code, the
+        # imported module is initialized, possibly after it has been already
+        # frozen.
+
+        # This is important when the module startup() function does something
+        # at runtime, like setting os.environ (posix module) or initializing
+        # the winsock library (_socket module)
+        w_posix = self.space.builtin_modules['posix']
+        w_demo = self.space.builtin_modules['_demo']
+
+        w_posix._cleanup_()
+        assert w_posix.startup_called == False
+        w_demo._cleanup_() # w_demo.appleveldefs['DemoError'] imports posix
+        assert w_posix.startup_called == False
+


More information about the pypy-commit mailing list