|
37 | 37 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
38 | 38 | # SOFTWARE.
|
39 | 39 |
|
40 |
| -from . import CPyExtTestCase, CPyExtFunction, unhandled_error_compare |
| 40 | +from . import CPyExtTestCase, CPyExtFunction, unhandled_error_compare, CPyExtType |
41 | 41 |
|
42 | 42 | __dir__ = __file__.rpartition("/")[0]
|
43 | 43 |
|
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) |
49 | 44 |
|
| 45 | +class TestCeval(CPyExtTestCase): |
50 | 46 | test_Py_EnterLeaveRecursiveCall = CPyExtFunction(
|
51 | 47 | # We don't know the exact limit on CPython since it uses the counter in
|
52 | 48 | # the interpreter as well.
|
@@ -81,3 +77,15 @@ def compile_module(self, name):
|
81 | 77 | arguments=["int n", "char* where"],
|
82 | 78 | cmpfunc=unhandled_error_compare
|
83 | 79 | )
|
| 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