Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r91684:1235016e2d2c
Date: 2017-07-04 21:27 +0100
http://bitbucket.org/pypy/pypy/changeset/1235016e2d2c/
Log: fix test_exception.py and stop using api object
diff --git a/pypy/module/cpyext/test/test_exception.py
b/pypy/module/cpyext/test/test_exception.py
--- a/pypy/module/cpyext/test/test_exception.py
+++ b/pypy/module/cpyext/test/test_exception.py
@@ -1,32 +1,37 @@
-from pypy.module.cpyext.test.test_api import BaseApiTest
+from pypy.module.cpyext.test.test_api import BaseApiTest, raises_w
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
from pypy.module.cpyext.pyobject import make_ref
+from pypy.module.cpyext.exception import (
+ PyExceptionInstance_Class, PyException_GetTraceback,
+ PyException_SetTraceback, PyException_GetContext, PyException_SetContext,
+ PyException_GetCause, PyException_SetCause)
class TestExceptions(BaseApiTest):
- def test_ExceptionInstance_Class(self, space, api):
+ def test_ExceptionInstance_Class(self, space):
w_instance = space.call_function(space.w_ValueError)
- assert api.PyExceptionInstance_Class(w_instance) is space.w_ValueError
+ assert PyExceptionInstance_Class(
+ space, w_instance) is space.w_ValueError
- def test_traceback(self, space, api):
+ def test_traceback(self, space):
w_exc = space.call_function(space.w_ValueError)
- assert api.PyException_GetTraceback(w_exc) is None
- assert api.PyException_SetTraceback(w_exc, space.wrap(1)) == -1
- api.PyErr_Clear()
+ assert PyException_GetTraceback(space, w_exc) is None
+ with raises_w(space, TypeError):
+ PyException_SetTraceback(space, w_exc, space.wrap(1))
- def test_context(self, space, api):
+ def test_context(self, space):
w_exc = space.call_function(space.w_ValueError)
- assert api.PyException_GetContext(w_exc) is None
+ assert PyException_GetContext(space, w_exc) is None
w_ctx = space.call_function(space.w_IndexError)
- api.PyException_SetContext(w_exc, make_ref(space, w_ctx))
- assert space.is_w(api.PyException_GetContext(w_exc), w_ctx)
+ PyException_SetContext(space, w_exc, make_ref(space, w_ctx))
+ assert space.is_w(PyException_GetContext(space, w_exc), w_ctx)
- def test_cause(self, space, api):
+ def test_cause(self, space):
w_exc = space.call_function(space.w_ValueError)
- assert api.PyException_GetCause(w_exc) is None
+ assert PyException_GetCause(space, w_exc) is None
w_cause = space.call_function(space.w_IndexError)
- api.PyException_SetCause(w_exc, make_ref(space, w_cause))
- assert space.is_w(api.PyException_GetCause(w_exc), w_cause)
+ PyException_SetCause(space, w_exc, make_ref(space, w_cause))
+ assert space.is_w(PyException_GetCause(space, w_exc), w_cause)
class AppTestExceptions(AppTestCpythonExtensionBase):
@@ -38,6 +43,5 @@
return PyTuple_Pack(2,
PyExc_EnvironmentError,
PyExc_IOError);
- """),
- ])
+ """)])
assert module.get_aliases() == (OSError, OSError)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit