mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
be robust against test being run over and over (such as -R)
This commit is contained in:
parent
a04ae012ce
commit
46bff79d1f
1 changed files with 13 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue