[pypy-commit] pypy stm-thread: Test and simple fix.
arigo
noreply at buildbot.pypy.org
Thu May 10 23:58:22 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread
Changeset: r55020:c3a23a83b80f
Date: 2012-05-10 23:58 +0200
http://bitbucket.org/pypy/pypy/changeset/c3a23a83b80f/
Log: Test and simple fix.
diff --git a/lib_pypy/pypy_test/test_transaction.py b/lib_pypy/pypy_test/test_transaction.py
--- a/lib_pypy/pypy_test/test_transaction.py
+++ b/lib_pypy/pypy_test/test_transaction.py
@@ -38,3 +38,34 @@
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
diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py
--- a/lib_pypy/transaction.py
+++ b/lib_pypy/transaction.py
@@ -8,7 +8,7 @@
"""
from __future__ import with_statement
-import thread, collections
+import sys, thread, collections
try:
from thread import atomic
More information about the pypy-commit
mailing list