-
-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy pathtest_arithmetic.py
More file actions
41 lines (31 loc) · 1.31 KB
/
test_arithmetic.py
File metadata and controls
41 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
from pendulum import Interval
from .. import AbstractTestCase
class ArithmeticTestCase(AbstractTestCase):
def test_multiply(self):
it = Interval(days=6, seconds=34, microseconds=522222)
mul = it * 2
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 1, 5, 0, 1, 9, 44444)
it = Interval(days=6, seconds=34, microseconds=522222)
mul = 2 * it
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 1, 5, 0, 1, 9, 44444)
def test_divide(self):
it = Interval(days=2, seconds=34, microseconds=522222)
mul = it / 2
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 0, 1, 0, 0, 17, 261111)
it = Interval(days=2, seconds=35, microseconds=522222)
mul = it / 2
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 0, 1, 0, 0, 17, 761111)
def test_floor_divide(self):
it = Interval(days=2, seconds=34, microseconds=522222)
mul = it // 2
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 0, 1, 0, 0, 17, 261111)
it = Interval(days=2, seconds=35, microseconds=522222)
mul = it // 3
self.assertIsInstanceOfInterval(mul)
self.assertInterval(mul, 0, 0, 16, 0, 11, 840740)