[pypy-commit] pypy raises(Exception)-must-die: modernise syntax of some py.test.raises calls
rlamy
noreply at buildbot.pypy.org
Tue Oct 13 21:54:38 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: raises(Exception)-must-die
Changeset: r80174:33d415293c92
Date: 2015-10-13 20:00 +0100
http://bitbucket.org/pypy/pypy/changeset/33d415293c92/
Log: modernise syntax of some py.test.raises calls
diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -769,7 +769,8 @@
def f():
return x
a = self.RPythonAnnotator(policy=AnnotatorPolicy())
- py.test.raises(Exception, a.build_types, f, [])
+ with py.test.raises(Exception):
+ a.build_types(f, [])
def test_exception_deduction_with_raise1(self):
a = self.RPythonAnnotator()
@@ -959,14 +960,16 @@
def f():
return large_constant
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, f, [])
+ with py.test.raises(Exception):
+ a.build_types(f, [])
# if you want to get a r_uint, you have to be explicit about it
def test_add_different_ints(self):
def f(a, b):
return a + b
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, f, [r_uint, int])
+ with py.test.raises(Exception):
+ a.build_types(f, [r_uint, int])
def test_merge_different_ints(self):
def f(a, b):
@@ -976,7 +979,8 @@
c = b
return c
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, f, [r_uint, int])
+ with py.test.raises(Exception):
+ a.build_types(f, [r_uint, int])
def test_merge_ruint_zero(self):
def f(a):
@@ -2694,7 +2698,8 @@
return a.x # should explode here
a = self.RPythonAnnotator()
- e = py.test.raises(Exception, a.build_types, f, [int])
+ with py.test.raises(Exception) as excinfo:
+ a.build_types(f, [int])
# this should explode on reading the attribute 'a.x', but it can
# sometimes explode on 'self.x = x', which does not make much sense.
# But it looks hard to fix in general: we don't know yet during 'a.x'
@@ -2928,7 +2933,8 @@
s = a.build_types(fun, [s_nonneg, s_nonneg])
assert isinstance(s, annmodel.SomeInteger)
assert not s.nonneg
- py.test.raises(Exception, a.build_types, fun, [int, int])
+ with py.test.raises(Exception):
+ a.build_types(fun, [int, int])
def test_sig_simpler(self):
def fun(x, y):
@@ -2940,7 +2946,8 @@
s = a.build_types(fun, [s_nonneg, s_nonneg])
assert isinstance(s, annmodel.SomeInteger)
assert not s.nonneg
- py.test.raises(Exception, a.build_types, fun, [int, int])
+ with py.test.raises(Exception):
+ a.build_types(fun, [int, int])
def test_sig_lambda(self):
def fun(x, y):
@@ -2954,7 +2961,8 @@
s = a.build_types(fun, [int, s_nonneg])
assert isinstance(s, annmodel.SomeInteger)
assert not s.nonneg
- py.test.raises(Exception, a.build_types, fun, [s_nonneg, int])
+ with py.test.raises(Exception):
+ a.build_types(fun, [s_nonneg, int])
def test_sig_bug(self):
def g(x, y=5):
@@ -3138,7 +3146,8 @@
return a.n()
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, fun, [bool])
+ with py.test.raises(Exception):
+ a.build_types(fun, [bool])
def test_float_cmp(self):
def fun(x, y):
@@ -3243,7 +3252,8 @@
i.x = x
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, f, [])
+ with py.test.raises(Exception):
+ a.build_types(f, [])
class M:
@@ -3342,7 +3352,8 @@
if g(x, y):
g(x, r_uint(y))
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, f, [int, int])
+ with py.test.raises(Exception):
+ a.build_types(f, [int, int])
def test_compare_with_zero(self):
def g():
@@ -4102,7 +4113,8 @@
e = cls()
e.foo = "bar"
a = self.RPythonAnnotator()
- py.test.raises(Exception, a.build_types, fn, [])
+ with py.test.raises(Exception):
+ a.build_types(fn, [])
def test_lower_char(self):
def fn(c):
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
@@ -126,7 +126,9 @@
else:
d = RWeakKeyDictionary(KY, VX)
d.set(KX(), VX())
- py.test.raises(Exception, interpret, g, [1])
+
+ with py.test.raises(Exception):
+ interpret(g, [1])
def g(x):
if x:
@@ -134,7 +136,9 @@
else:
d = RWeakKeyDictionary(KX, VY)
d.set(KX(), VX())
- py.test.raises(Exception, interpret, g, [1])
+
+ with py.test.raises(Exception):
+ interpret(g, [1])
def test_rpython_free_values():
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
@@ -143,7 +143,9 @@
else:
d = RWeakValueDictionary(str, Y)
d.set("x", X())
- py.test.raises(Exception, interpret, g, [1])
+
+ with py.test.raises(Exception):
+ interpret(g, [1])
def test_rpython_RWeakValueDictionary_or_None():
diff --git a/rpython/rtyper/test/test_extfunc.py b/rpython/rtyper/test/test_extfunc.py
--- a/rpython/rtyper/test/test_extfunc.py
+++ b/rpython/rtyper/test/test_extfunc.py
@@ -152,7 +152,8 @@
a.translator.config.translation.check_str_without_nul=True
def g(s):
return os_open(s)
- py.test.raises(Exception, a.build_types, g, [str])
+ with py.test.raises(Exception):
+ a.build_types(g, [str])
a.build_types(g, [str0]) # Does not raise
def test_list_of_str0(self):
@@ -170,7 +171,8 @@
a.translator.config.translation.check_str_without_nul=True
def g(l):
return os_execve(l)
- py.test.raises(Exception, a.build_types, g, [[str]])
+ with py.test.raises(Exception):
+ a.build_types(g, [[str]])
a.build_types(g, [[str0]]) # Does not raise
More information about the pypy-commit
mailing list