Author: Carl Friedrich Bolz-Tereick
Branch: py3.6
Changeset: r97472:6e832892a7f7
Date: 2019-09-13 13:00 +0200
http://bitbucket.org/pypy/pypy/changeset/6e832892a7f7/
Log:merge default
diff --git a/pypy/config/test/test_pypyoption.py
b/pypy/config/test/test_pypyoption.py
--- a/pypy/config/test/test_pypyoption.py
+++ b/pypy/config/test/test_pypyoption.py
@@ -8,14 +8,13 @@
def test_required():
conf = get_pypy_config()
assert not conf.translating
-
assert conf.objspace.usemodules.gc
def test_conflicting_gcrootfinder():
conf = get_pypy_config()
conf.translation.gc = "boehm"
-py.test.raises(ConfigError, "conf.translation.gcrootfinder = 'asmgcc'")
-
+with py.test.raises(ConfigError):
+conf.translation.gcrootfinder = 'asmgcc'
def test_frameworkgc():
for name in ["minimark", "semispace"]:
diff --git a/pypy/interpreter/test/apptest_pyframe.py
b/pypy/interpreter/test/apptest_pyframe.py
--- a/pypy/interpreter/test/apptest_pyframe.py
+++ b/pypy/interpreter/test/apptest_pyframe.py
@@ -13,7 +13,8 @@
import sys
f = sys._getframe()
assert f.f_globals is globals()
-pytest.raises(AttributeError, "f.f_globals = globals()")
+with pytest.raises(AttributeError):
+f.f_globals = globals()
def test_f_builtins():
import sys, builtins
diff --git a/pypy/interpreter/test/test_function.py
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -160,7 +160,8 @@
return 41
assert f() == 42
assert g() == 41
-raises(TypeError, "f.__code__ = 1")
+with raises(TypeError):
+f.__code__ = 1
f.__code__ = g.__code__
assert f() == 41
def get_h(f=f):
@@ -168,14 +169,17 @@
return f() # a closure
return h
h = get_h()
-raises(ValueError, "f.__code__ = h.__code__")
+with raises(ValueError):
+f.__code__ = h.__code__
@pytest.mark.skipif("config.option.runappdirect")
def test_write_code_builtin_forbidden(self):
def f(*args):
return 42
-raises(TypeError, "dir.__code__ = f.__code__")
-raises(TypeError, "list.append.__code__ = f.__code__")
+with raises(TypeError):
+dir.__code__ = f.__code__
+with raises(TypeError):
+list.append.__code__ = f.__code__
def test_set_module_to_name_eagerly(self):
skip("fails on PyPy but works on CPython. Unsure we want to care")
@@ -313,19 +317,10 @@
def func(self, **kw):
return self, kw
func = A().func
-
-# don't want the extra argument passing of raises
-try:
+with raises(TypeError):
func(self=23)
-assert False
-except TypeError:
-pass
-
-try:
+with raises(TypeError):
func(**{'self': 23})
-assert False
-except TypeError:
-pass
def test_kwargs_confusing_name(self):
def func(self):# 'self' conflicts with the interp-level
diff --git a/pypy/interpreter/test/test_nestedscope.py
b/pypy/interpreter/test/test_nestedscope.py
--- a/pypy/interpreter/test/test_nestedscope.py
+++ b/pypy/interpreter/test/test_nestedscope.py
@@ -99,7 +99,8 @@
x = 1
g = f()
-raises(ValueError, "g.__closure__[0].cell_contents")
+with raises(ValueError):
+g.__closure__[0].cell_contents
def test_compare_cells(self):
def f(n):
diff --git a/pypy/interpreter/test/test_raise.py
b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -2,9 +2,8 @@
class AppTestRaise:
def test_arg_as_string(self):
-def f():
+with raises(TypeError):
raise "test"
-raises(TypeError, f)
def test_control_flow(self):
try:
@@ -36,9 +35,8 @@
assert isinstance(e, IndexError)
def test_raise_cls(self):
-def f():
+with raises(IndexError):
raise IndexError
-raises(IndexError, f)
def test_raise_cls_catch(self):
def f(r):
@@ -46,7 +44,8 @@
raise r
except LookupError:
return 1
-raises(Exception, f, Exception)
+with raises(Exception):
+f(Exception)
assert f(IndexError) == 1
def test_raise_wrong(self):
@@ -99,7 +98,7 @@
assert sys.exc_info() == (None, None, None)
def test_reraise_1(self):
-raises(IndexError, """
+with raises(IndexError):
import sys
try:
raise ValueError
@@ -109,10 +108,10 @@
finally:
assert sys.exc_info()[0] is IndexError
raise
-""")
+
def test_reraise_2(self):
-