def test_FromSeconds(self): from _testcapi import PyTime_FromSeconds # PyTime_FromSeconds() expects a C int, reject values out of range def c_int_filter(secs): return (_testcapi.INT_MIN <= secs <= _testcapi.INT_MAX) self.check_int_rounding(lambda secs, rnd: PyTime_FromSeconds(secs), lambda secs: secs * SEC_TO_NS, value_filter=c_int_filter) # test nan for time_rnd, _ in ROUNDING_MODES: with self.assertRaises(TypeError): PyTime_FromSeconds(float('nan'))
def test_FromSeconds(self): from _testcapi import PyTime_FromSeconds def c_int_filter(secs): return _testcapi.INT_MIN <= secs <= _testcapi.INT_MAX self.check_int_rounding(lambda secs, rnd: PyTime_FromSeconds(secs), lambda secs: secs * SEC_TO_NS, value_filter=c_int_filter)
def test_FromSeconds(self): from _testcapi import PyTime_FromSeconds # PyTime_FromSeconds() expects a C int, reject values out of range def c_int_filter(secs): return (_testcapi.INT_MIN <= secs <= _testcapi.INT_MAX) self.check_int_rounding(lambda secs, rnd: PyTime_FromSeconds(secs), lambda secs: secs * SEC_TO_NS, value_filter=c_int_filter)
def test_FromSeconds(self): from _testcapi import PyTime_FromSeconds for seconds in (0, 3, -456, _testcapi.INT_MAX, _testcapi.INT_MIN): with self.subTest(seconds=seconds): self.assertEqual(PyTime_FromSeconds(seconds), seconds * SEC_TO_NS)