Author: Armin Rigo <[email protected]>
Branch: signal-and-thread
Changeset: r61277:622fccdeb60f
Date: 2013-02-15 17:28 +0000
http://bitbucket.org/pypy/pypy/changeset/622fccdeb60f/

Log:    Add a test, which (most probably) only works on "pypy py.test -A".

diff --git a/pypy/module/thread/test/test_signal.py 
b/pypy/module/thread/test/test_signal.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/thread/test/test_signal.py
@@ -0,0 +1,32 @@
+import sys
+
+
+class AppTest:
+    spaceconfig = dict(usemodules=['thread', 'signal'])
+
+    def setup_class(cls):
+        if (not cls.runappdirect or
+                '__pypy__' not in sys.builtin_module_names):
+            import py
+            py.test.skip("this is only a test for -A runs on top of pypy")
+
+    def test_enable_signals(self):
+        import thread, signal, time
+        #
+        interrupted = []
+        lock = thread.allocate_lock()
+        lock.acquire()
+        #
+        def subthread():
+            try:
+                time.sleep(0.25)
+                with thread.signals_enabled:
+                    thread.interrupt_main()
+            except BaseException, e:
+                interrupted.append(e)
+            lock.release()
+        #
+        thread.start_new_thread(subthread, ())
+        lock.acquire()
+        assert len(interrupted) == 1
+        assert 'KeyboardInterrupt' in interrupted[0].__class__.__name__
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to