Beispiel #1
0
 def test_sub_unsupported(self):
     p = Interval(days=23, seconds=32)
     self.assertEqual(NotImplemented, p.__sub__(5))
Beispiel #2
0
    def test_add_timedelta(self):
        p1 = Interval(days=23, seconds=32)
        p2 = timedelta(days=12, seconds=30)

        p = p1 + p2
        self.assertInterval(p, 5, 0, 0, 1, 2)
Beispiel #3
0
    def test_sub_timedelta(self):
        p1 = Interval(days=23, seconds=32)
        p2 = timedelta(days=12, seconds=28)

        p = p1 - p2
        self.assertInterval(p, 1, 4, 0, 0, 4)
Beispiel #4
0
 def test_all(self):
     pi = Interval(days=1177, seconds=7284, microseconds=1000000)
     self.assertInterval(pi, 168, 1, 2, 1, 25)
Beispiel #5
0
    def setUp(self):
        super(ForHumansTest, self).setUp()

        Interval.set_locale('en')
Beispiel #6
0
    def test_weeks(self):
        pi = Interval(days=365)
        self.assertInterval(pi, 52)

        pi = Interval(days=13)
        self.assertInterval(pi, 1)
Beispiel #7
0
 def test_hours(self):
     pi = Interval(seconds=3600 * 3)
     self.assertInterval(pi, 0, 0, 3, 0, 0)
Beispiel #8
0
 def test_all(self):
     pi = Interval(days=1177, seconds=7284, microseconds=1000000)
     self.assertEqual(
         '168 weeks 1 day 2 hours 1 minute 25 seconds',
         pi.in_words()
     )
Beispiel #9
0
 def test_in_french(self):
     pi = Interval(days=1177, seconds=7284, microseconds=1000000)
     self.assertEqual(
         '168 semaines 1 jour 2 heures 1 minute 25 secondes',
         pi.in_words(locale='fr')
     )
Beispiel #10
0
 def test_week_to_string(self):
     self.assertEqual('52 weeks', str(Interval(days=364)))
     self.assertEqual('1 week', str(Interval(days=7)))
Beispiel #11
0
 def test_weeks_and_day(self):
     self.assertEqual('52 weeks 1 day', Interval(days=365).in_words())
Beispiel #12
0
 def test_week(self):
     self.assertEqual('52 weeks', Interval(days=364).in_words())
     self.assertEqual('1 week', Interval(days=7).in_words())
Beispiel #13
0
    def test_invert(self):
        pi = Interval(days=1177, seconds=7284, microseconds=1000000)
        self.assertFalse(pi.invert)

        pi = Interval(days=-1177, seconds=-7284, microseconds=-1000000)
        self.assertTrue(pi.invert)
Beispiel #14
0
 def test_instance(self):
     pi = Interval.instance(
         timedelta(days=1177, seconds=7284, microseconds=1000000))
     self.assertInterval(pi, 168, 1, 2, 1, 25)
Beispiel #15
0
 def test_neg(self):
     p = Interval(days=23, seconds=32)
     self.assertInterval(-p, -3, -2, 0, 0, -32)
Beispiel #16
0
 def test_repr(self):
     pi = Interval(days=1177, seconds=7284, microseconds=1000000)
     self.assertEqual(
         '<Interval [168 weeks 1 day 2 hours 1 minute 25 seconds]>',
         repr(pi)
     )
Beispiel #17
0
 def test_defaults(self):
     pi = Interval()
     self.assertIsInstanceOfInterval(pi)
     self.assertInterval(pi, 0, 0, 0, 0, 0)
Beispiel #18
0
 def test_singluar_negative_values(self):
     pi = Interval(days=-1)
     self.assertEqual(
         '-1 day',
         pi.in_words()
     )
Beispiel #19
0
    def test_days(self):
        pi = Interval(days=6)
        self.assertInterval(pi, 0, 6, 0, 0, 0)

        pi = Interval(days=16)
        self.assertInterval(pi, 2, 2, 0, 0, 0)
Beispiel #20
0
 def test_separator(self):
     pi = Interval(days=1177, seconds=7284, microseconds=1000000)
     self.assertEqual(
         '168 weeks, 1 day, 2 hours, 1 minute, 25 seconds',
         pi.in_words(separator=', ')
     )
Beispiel #21
0
    def test_minutes(self):
        pi = Interval(seconds=60 * 3)
        self.assertInterval(pi, 0, 0, 0, 3, 0)

        pi = Interval(seconds=60 * 3 + 12)
        self.assertInterval(pi, 0, 0, 0, 3, 12)
Beispiel #22
0
def getDateList(start, end):
    dif = int((end - start).total_seconds() / 3600)
    date_list = [(start + Interval(hours=x)) for x in range(dif)]
    return date_list