Ejemplo n.º 1
0
    def test_humanize_duration(self):
        test_subjects = (
            (timedelta(days=1, hours=1, minutes=1,
                       seconds=1), '1 day, 1 hour, 1 minute, 1 second'),
            (timedelta(days=2), '2 days'),
            (timedelta(days=15, minutes=4), '15 days, 4 minutes'),
            (timedelta(), '< 1 second'),
        )

        for duration, humanized in test_subjects:
            self.assertEqual(humanize_duration(duration), humanized)
Ejemplo n.º 2
0
    def test_humanize_duration(self):
        test_subjects = (
            (timedelta(days=1, hours=1, minutes=1, seconds=1), '1 day, 1 hour, 1 minute, 1 second'),
            (timedelta(days=2), '2 days'),
            (timedelta(days=15, minutes=4), '15 days, 4 minutes'),
            (timedelta(), '< 1 second'),
        )

        for duration, humanized in test_subjects:
            self.assertEqual(
                humanize_duration(duration),
                humanized
            )
Ejemplo n.º 3
0
 def humanize_duration(self, obj):
     return humanize_duration(obj.end_time - obj.start_time)