]> granicus.if.org Git - python/commitdiff
be robust against test being run over and over (such as -R)
authorBenjamin Peterson <benjamin@python.org>
Sat, 30 Jan 2010 23:28:38 +0000 (23:28 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 30 Jan 2010 23:28:38 +0000 (23:28 +0000)
Modules/_testcapimodule.c

index 1d889ddb3237df488b55d0e2c1a6aacf4b3f24fb..85bc75f101a6920577ea6c72caf814a5f5a380bf 100644 (file)
@@ -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;