[pypy-commit] pypy cpyext-leakchecking: fix some tests
rlamy
pypy.commits at gmail.com
Tue Aug 1 22:59:58 EDT 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: cpyext-leakchecking
Changeset: r92026:398723725f36
Date: 2017-08-02 03:59 +0100
http://bitbucket.org/pypy/pypy/changeset/398723725f36/
Log: fix some tests
diff --git a/pypy/module/cpyext/test/test_eval.py b/pypy/module/cpyext/test/test_eval.py
--- a/pypy/module/cpyext/test/test_eval.py
+++ b/pypy/module/cpyext/test/test_eval.py
@@ -279,6 +279,7 @@
assert module.call_method("text") == 2
def test_CompileString_and_Exec(self):
+ import sys
module = self.import_extension('foo', [
("compile_string", "METH_NOARGS",
"""
@@ -313,6 +314,9 @@
print mod.__dict__
assert mod.f(42) == 47
+ # Clean-up
+ del sys.modules['cpyext_test_modname']
+
def test_merge_compiler_flags(self):
module = self.import_extension('foo', [
("get_flags", "METH_NOARGS",
@@ -357,4 +361,4 @@
except RuntimeError as e:
assert 'while calling recurse' in str(e)
else:
- assert False, "expected RuntimeError"
+ assert False, "expected RuntimeError"
diff --git a/pypy/module/cpyext/test/test_floatobject.py b/pypy/module/cpyext/test/test_floatobject.py
--- a/pypy/module/cpyext/test/test_floatobject.py
+++ b/pypy/module/cpyext/test/test_floatobject.py
@@ -104,6 +104,7 @@
PyFloatObject* pfo = (PyFloatObject*)pyobj;
int res = PyFloat_Check(pyobj) && PyFloat_CheckExact(pyobj) &&
PyFloat_Check(pfo) && PyFloat_CheckExact(pfo);
+ Py_DecRef(pyobj);
return PyLong_FromLong(res);"""),
])
assert module.test() == 1
diff --git a/pypy/module/cpyext/test/test_funcobject.py b/pypy/module/cpyext/test/test_funcobject.py
--- a/pypy/module/cpyext/test/test_funcobject.py
+++ b/pypy/module/cpyext/test/test_funcobject.py
@@ -46,7 +46,7 @@
w_function = space.appexec([], """():
def func(x, y, z): return x
return func
- """)
+ """, cache=False)
w_code = PyFunction_GetCode(space, w_function)
assert w_code.co_name == "func"
@@ -63,7 +63,7 @@
w_code = space.appexec([], """():
def func(%s): %s
return func.__code__
- """ % (signature, body))
+ """ % (signature, body), cache=False)
ref = make_ref(space, w_code)
co_flags = rffi.cast(PyCodeObject, ref).c_co_flags
decref(space, ref)
diff --git a/pypy/module/cpyext/test/test_longobject.py b/pypy/module/cpyext/test/test_longobject.py
--- a/pypy/module/cpyext/test/test_longobject.py
+++ b/pypy/module/cpyext/test/test_longobject.py
@@ -313,6 +313,7 @@
ret = obj->ob_type->tp_as_number->nb_power(obj, one, one);
else
ret = PyLong_FromLong(-1);
+ Py_DECREF(one);
Py_DECREF(obj);
return ret;
"""),
@@ -340,4 +341,3 @@
assert module.has_pow() == 0
assert module.has_hex() == '0x2aL'
assert module.has_oct() == '052L'
-
More information about the pypy-commit
mailing list