Skip to content

Commit e00960a

Browse files
authored
gh-110850: Enhance PyTime C API tests (#115715)
1 parent 1ff6c14 commit e00960a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Modules/_testcapi/time.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ static PyObject*
4949
test_pytime_monotonic(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
5050
{
5151
PyTime_t t;
52-
if (PyTime_Monotonic(&t) < 0) {
52+
int res = PyTime_Monotonic(&t);
53+
if (res < 0) {
5354
return NULL;
5455
}
56+
assert(res == 0);
5557
return pytime_as_float(t);
5658
}
5759

@@ -60,9 +62,11 @@ static PyObject*
6062
test_pytime_perf_counter(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
6163
{
6264
PyTime_t t;
63-
if (PyTime_PerfCounter(&t) < 0) {
65+
int res = PyTime_PerfCounter(&t);
66+
if (res < 0) {
6467
return NULL;
6568
}
69+
assert(res == 0);
6670
return pytime_as_float(t);
6771
}
6872

@@ -71,10 +75,11 @@ static PyObject*
7175
test_pytime_time(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
7276
{
7377
PyTime_t t;
74-
if (PyTime_Time(&t) < 0) {
75-
printf("ERR! %d\n", (int)t);
78+
int res = PyTime_Time(&t);
79+
if (res < 0) {
7680
return NULL;
7781
}
82+
assert(res == 0);
7883
return pytime_as_float(t);
7984
}
8085

0 commit comments

Comments
 (0)