From 68a16aa5cbb824c6a9196b24540d5e6d89e543f4 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 20 Feb 2024 15:07:27 +0100 Subject: [PATCH] gh-110850: Enhance PyTime C API tests --- Modules/_testcapi/time.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/_testcapi/time.c b/Modules/_testcapi/time.c index 57eb9135d30029..68f082bf3f3d88 100644 --- a/Modules/_testcapi/time.c +++ b/Modules/_testcapi/time.c @@ -49,9 +49,11 @@ static PyObject* test_pytime_monotonic(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { PyTime_t t; - if (PyTime_Monotonic(&t) < 0) { + int res = PyTime_Monotonic(&t); + if (res < 0) { return NULL; } + assert(res == 0); return pytime_as_float(t); } @@ -60,9 +62,11 @@ static PyObject* test_pytime_perf_counter(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { PyTime_t t; - if (PyTime_PerfCounter(&t) < 0) { + int res = PyTime_PerfCounter(&t); + if (res < 0) { return NULL; } + assert(res == 0); return pytime_as_float(t); } @@ -71,10 +75,11 @@ static PyObject* test_pytime_time(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { PyTime_t t; - if (PyTime_Time(&t) < 0) { - printf("ERR! %d\n", (int)t); + int res = PyTime_Time(&t); + if (res < 0) { return NULL; } + assert(res == 0); return pytime_as_float(t); }