[pypy-commit] pypy raises(Exception)-must-die: fix tests and missing import for rweakref
rlamy
noreply at buildbot.pypy.org
Wed Oct 14 00:34:13 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: raises(Exception)-must-die
Changeset: r80182:a5ba716fb184
Date: 2015-10-13 23:26 +0100
http://bitbucket.org/pypy/pypy/changeset/a5ba716fb184/
Log: fix tests and missing import for rweakref
diff --git a/rpython/rlib/rweakref.py b/rpython/rlib/rweakref.py
--- a/rpython/rlib/rweakref.py
+++ b/rpython/rlib/rweakref.py
@@ -2,10 +2,10 @@
Weakref support in RPython. Basic regular weakrefs without callbacks
are supported. This file contains the following additions:
a form of WeakKeyDictionary, and a limited version of WeakValueDictionary.
-LLType only for now!
"""
import weakref
+from rpython.annotator.model import UnionError
ref = weakref.ref # basic regular weakrefs are supported in RPython
@@ -191,9 +191,9 @@
class __extend__(pairtype(SomeWeakKeyDict, SomeWeakKeyDict)):
def union((s_wkd1, s_wkd2)):
if s_wkd1.keyclassdef is not s_wkd2.keyclassdef:
- raise UnionError(w_wkd1, s_wkd2, "not the same key class!")
+ raise UnionError(s_wkd1, s_wkd2, "not the same key class!")
if s_wkd1.valueclassdef is not s_wkd2.valueclassdef:
- raise UnionError(w_wkd1, s_wkd2, "not the same value class!")
+ raise UnionError(s_wkd1, s_wkd2, "not the same value class!")
return SomeWeakKeyDict(s_wkd1.keyclassdef, s_wkd1.valueclassdef)
class Entry(extregistry.ExtRegistryEntry):
diff --git a/rpython/rlib/test/test_rweakkeydict.py b/rpython/rlib/test/test_rweakkeydict.py
--- a/rpython/rlib/test/test_rweakkeydict.py
+++ b/rpython/rlib/test/test_rweakkeydict.py
@@ -1,4 +1,5 @@
import py
+from rpython.annotator.model import UnionError
from rpython.rlib import rgc
from rpython.rlib.rweakref import RWeakKeyDictionary
from rpython.rtyper.test.test_llinterp import interpret
@@ -120,6 +121,9 @@
f(1)
interpret(f, [1])
+ at py.test.mark.xfail(
+ reason="may fail with AssertionError, depending on annotation order")
+def test_rpython_merge_RWeakKeyDictionary3():
def g(x):
if x:
d = RWeakKeyDictionary(KX, VX)
@@ -127,9 +131,12 @@
d = RWeakKeyDictionary(KY, VX)
d.set(KX(), VX())
- with py.test.raises(Exception):
+ with py.test.raises(UnionError):
interpret(g, [1])
+ at py.test.mark.xfail(
+ reason="may fail with AssertionError, depending on annotation order")
+def test_rpython_merge_RWeakKeyDictionary4():
def g(x):
if x:
d = RWeakKeyDictionary(KX, VX)
@@ -137,12 +144,11 @@
d = RWeakKeyDictionary(KX, VY)
d.set(KX(), VX())
- with py.test.raises(Exception):
+ with py.test.raises(UnionError):
interpret(g, [1])
-
+ at py.test.mark.xfail(reason="not implemented, messy")
def test_rpython_free_values():
- import py; py.test.skip("XXX not implemented, messy")
class VXDel:
def __del__(self):
state.freed.append(1)
diff --git a/rpython/rlib/test/test_rweakvaldict.py b/rpython/rlib/test/test_rweakvaldict.py
--- a/rpython/rlib/test/test_rweakvaldict.py
+++ b/rpython/rlib/test/test_rweakvaldict.py
@@ -1,4 +1,5 @@
import py
+from rpython.annotator.model import UnionError
from rpython.rlib import rgc
from rpython.rlib.rweakref import RWeakValueDictionary
from rpython.rtyper.test.test_llinterp import interpret
@@ -144,7 +145,7 @@
d = RWeakValueDictionary(str, Y)
d.set("x", X())
- with py.test.raises(Exception):
+ with py.test.raises(UnionError):
interpret(g, [1])
More information about the pypy-commit
mailing list