Armin Rigo avatar Armin Rigo committed c3a23a8

Test and simple fix.

Comments (0)

Files changed (2)

lib_pypy/pypy_test/test_transaction.py

         transaction.run()
         print lsts
         assert lsts == (range(10),) * 5
+
+def test_raise():
+    class FooError(Exception):
+        pass
+    for x in range(N):
+        lsts = ([], [], [], [], [], [], [], [], [], [])
+        def do_stuff(i, j):
+            lsts[i].append(j)
+            j += 1
+            if j < 5:
+                transaction.add(do_stuff, i, j)
+            else:
+                lsts[i].append('foo')
+                raise FooError
+        for i in range(10):
+            transaction.add(do_stuff, i, 0)
+        try:
+            transaction.run()
+        except FooError:
+            pass
+        else:
+            raise AssertionError("should have raised FooError")
+        print lsts
+        num_foos = 0
+        for lst in lsts:
+            if len(lst) < 5:
+                assert lst == range(len(lst))
+            else:
+                assert lst == range(5) + ['foo']
+                num_foos += 1
+        assert num_foos == 1

lib_pypy/transaction.py

 """
 
 from __future__ import with_statement
-import thread, collections
+import sys, thread, collections
 
 try:
     from thread import atomic
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.