示例#1
0
    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'))
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
 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)