summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-12-13 21:27:53 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-12-13 21:27:53 (GMT)
commit001e4a6c073b6b811cb4de6a0275494c057a6b8b (patch)
treebf205cd9326e59ca6ff1b5a434d744245a7ef63f /Modules/_testcapimodule.c
parent3095d20a53e1ee2d45c037bffeae6acb1ea165dd (diff)
downloadcpython-001e4a6c073b6b811cb4de6a0275494c057a6b8b.zip
cpython-001e4a6c073b6b811cb4de6a0275494c057a6b8b.tar.gz
cpython-001e4a6c073b6b811cb4de6a0275494c057a6b8b.tar.bz2
add a test of loading the datetime capi
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index f2181eb..c5c2c6b 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -8,6 +8,7 @@
#include "Python.h"
#include <float.h>
#include "structmember.h"
+#include "datetime.h"
#ifdef WITH_THREAD
#include "pythread.h"
@@ -806,6 +807,20 @@ raise_exception(PyObject *self, PyObject *args)
#ifdef WITH_THREAD
+static PyObject *
+test_datetime_capi(PyObject *self, PyObject *args) {
+ if (PyDateTimeAPI) {
+ PyErr_SetString(PyExc_AssertionError,
+ "PyDateTime_CAPI somehow initialized");
+ return NULL;
+ }
+ PyDateTime_IMPORT;
+ if (PyDateTimeAPI)
+ Py_RETURN_NONE;
+ else
+ return NULL;
+}
+
/* test_thread_state spawns a thread of its own, and that thread releases
* `thread_done` when it's finished. The driver code has to know when the
* thread finishes, because the thread uses a PyObject (the callable) that
@@ -1012,6 +1027,7 @@ code_newempty(PyObject *self, PyObject *args)
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
+ {"test_datetime_capi", test_datetime_capi, METH_NOARGS},
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},
{"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS},
{"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS},