Beispiel #1
0
    def test_accuracy(self):
        tiny = Duration.resolution
        # Make sure we can make a Duration that uses Long:
        m = Duration(2 ** 65, seconds=1234, microseconds=567890)

        # The total_microseconds() can give as accuracy:
        self.assertEqual(m.total_microseconds(), 3187597375937010519246034567890)

        # Float can handle this many days:
        self.assertEqual(m.days, int(m.total_days()))
        # Float does not have the accuracy for the seconds in this case:
        self.assertEqual(m.total_microseconds() - int(m.total_seconds() * 1000000), 1234567890)
        self.assertEqual(m.total_microseconds() - int(m.total_days() * 86400000000), 1234567890)