summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-01-30 23:28:38 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-01-30 23:28:38 (GMT)
commit46bff79d1ffa0308bf902fc8961365d7d2fb2c1a (patch)
treed4925c7b810dd8cc04a3a44991c81a544277dbd8
parenta04ae012cede11d49d4df4551500cc0ba07b3dfb (diff)
downloadcpython-46bff79d1ffa0308bf902fc8961365d7d2fb2c1a.zip
cpython-46bff79d1ffa0308bf902fc8961365d7d2fb2c1a.tar.gz
cpython-46bff79d1ffa0308bf902fc8961365d7d2fb2c1a.tar.bz2
be robust against test being run over and over (such as -R)
-rw-r--r--Modules/_testcapimodule.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 1d889dd..85bc75f 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1144,13 +1144,23 @@ raise_exception(PyObject *self, PyObject *args)
return NULL;
}
+
+static int test_run_counter = 0;
+
static PyObject *
test_datetime_capi(PyObject *self, PyObject *args) {
if (PyDateTimeAPI) {
- PyErr_SetString(PyExc_AssertionError,
- "PyDateTime_CAPI somehow initialized");
- return NULL;
+ if (test_run_counter) {
+ /* Probably regrtest.py -R */
+ Py_RETURN_NONE;
+ }
+ else {
+ PyErr_SetString(PyExc_AssertionError,
+ "PyDateTime_CAPI somehow initialized");
+ return NULL;
+ }
}
+ test_run_counter++;
PyDateTime_IMPORT;
if (PyDateTimeAPI)
Py_RETURN_NONE;