Skip to content

Commit f2048f0

Browse files
committed
Add test for PyEval_GetGlobals
1 parent cc59a2c commit f2048f0

File tree

1 file changed

+14
-6
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+14
-6
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_ceval.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,12 @@
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
3939

40-
from . import CPyExtTestCase, CPyExtFunction, unhandled_error_compare
40+
from . import CPyExtTestCase, CPyExtFunction, unhandled_error_compare, CPyExtType
4141

4242
__dir__ = __file__.rpartition("/")[0]
4343

44-
class TestCeval(CPyExtTestCase):
45-
46-
def compile_module(self, name):
47-
type(self).mro()[1].__dict__["test_%s" % name].create_module(name)
48-
super(TestCeval, self).compile_module(name)
4944

45+
class TestCeval(CPyExtTestCase):
5046
test_Py_EnterLeaveRecursiveCall = CPyExtFunction(
5147
# We don't know the exact limit on CPython since it uses the counter in
5248
# the interpreter as well.
@@ -81,3 +77,15 @@ def compile_module(self, name):
8177
arguments=["int n", "char* where"],
8278
cmpfunc=unhandled_error_compare
8379
)
80+
81+
def test_PyEval_GetGlobals(self):
82+
Tester = CPyExtType(
83+
"GetGlobalsTester",
84+
code="""
85+
static PyObject* get_globals(PyObject* unused) {
86+
return Py_NewRef(PyEval_GetGlobals());
87+
}
88+
""",
89+
tp_methods='{"get_globals", (PyCFunction)get_globals, METH_NOARGS | METH_STATIC, NULL}',
90+
)
91+
assert Tester.get_globals() is globals()

0 commit comments

Comments
 (0)