示例#1
0
文件: time_test.py 项目: wr41thx/dmc
    def test_cmp(self):
        assert_equal(TimeInterval(2.22), TimeInterval(2, microseconds=220000))

        assert_gt(TimeInterval(2.22), TimeInterval(2.20))
        assert_gt(TimeInterval(3.22), TimeInterval(2.5))

        assert_lt(TimeInterval(0), TimeInterval(microseconds=1))
        assert_lt(TimeInterval(-3), TimeInterval(2.5))
示例#2
0
文件: time_test.py 项目: wr41thx/dmc
    def test_div_micro(self):
        i1 = TimeInterval(2, microseconds=22)

        i2 = i1 / 2

        assert_equal(i2.seconds, 1)
        assert_equal(i2.microseconds, 11)
示例#3
0
文件: time_test.py 项目: wr41thx/dmc
    def test(self):
        start_t = Time.now()
        end_t = start_t + 5*60

        times = list(TimeSpanIterator(TimeSpan(start_t, end_t), TimeInterval(60)))
        assert_equal(len(times), 5)
        assert_equal(times[0].start, start_t)
        assert_equal(times[-1].end, end_t)
示例#4
0
文件: time_test.py 项目: wr41thx/dmc
    def test_time_add(self):
        t1 = Time(2014, 4, 18, 17, 50, 21)
        ti = TimeInterval(2.22)

        t2 = t1 + ti

        assert_equal(t2.second, 23)
        assert_equal(t2.microsecond, 220000)
示例#5
0
文件: time_test.py 项目: wr41thx/dmc
    def test_time_sub(self):
        t1 = Time(2014, 4, 18, 17, 50, 21)
        ti = TimeInterval(2.22)

        t2 = t1 - ti

        assert_equal(t2.second, 18)
        assert_equal(t2.microsecond, 780000)
示例#6
0
文件: time_test.py 项目: wr41thx/dmc
    def test_timedelta(self):
        td = datetime.timedelta(days=1, seconds=10, microseconds=1000)

        i = TimeInterval.from_timedelta(td)

        assert_equal(i.seconds, round(td.total_seconds()))
        assert_equal(i.microseconds, td.microseconds)
        assert_equal(float(i), td.total_seconds())
示例#7
0
文件: time_test.py 项目: wr41thx/dmc
    def test_sub_int(self):
        i1 = TimeInterval(2)
        i2 = 1

        i3 = i1 - i2
        assert_equal(i3.seconds, 1)

        i4 = i2 - i1
        assert_equal(i4, -1)
示例#8
0
文件: time_test.py 项目: wr41thx/dmc
    def test_add_int(self):
        i1 = TimeInterval(1)
        i2 = 1

        i3 = i1 + i2
        assert_equal(i3.seconds, 2)

        i4 = i2 + i1
        assert_equal(i4.seconds, 2)
示例#9
0
文件: time_test.py 项目: wr41thx/dmc
    def test_div(self):
        i1 = TimeInterval(5)

        i2 = i1 / 2

        assert_equal(float(i2), 2.5)
示例#10
0
文件: time_test.py 项目: wr41thx/dmc
    def test_mul(self):
        i1 = TimeInterval(2)

        i2 = i1 * 3

        assert_equal(int(i2), 6)
示例#11
0
文件: time_test.py 项目: wr41thx/dmc
    def test_sub_neg(self):
        i1 = TimeInterval(1)
        i2 = TimeInterval(2)

        i3 = i1 - i2
        assert_equal(i3.seconds, -1)
示例#12
0
文件: time_test.py 项目: wr41thx/dmc
 def test_hours(self):
     i = TimeInterval(hours=1)
     assert_equal(i.seconds, 3600)
     assert_equal(i.microseconds, 0)
示例#13
0
文件: time_test.py 项目: wr41thx/dmc
    def test_seconds(self):
        i = TimeInterval(21)

        assert_equal(i.seconds, 21)
        assert_equal(i.microseconds, 0)
示例#14
0
文件: time_test.py 项目: wr41thx/dmc
 def test_int_round(self):
     i = TimeInterval(4, microseconds=600000)
     assert_equal(int(i), 5)
示例#15
0
文件: time_test.py 项目: wr41thx/dmc
 def test_int(self):
     i = TimeInterval(4)
     assert_equal(int(i), 4)
示例#16
0
文件: time_test.py 项目: wr41thx/dmc
 def test_microsecond_overflow(self):
     i = TimeInterval(seconds=1.9, microseconds=200000)
     assert_equal(i.seconds, 2)
     assert_equal(i.microseconds, 100000)
示例#17
0
文件: time_test.py 项目: wr41thx/dmc
 def test_microseconds(self):
     i = TimeInterval(microseconds=10)
     assert_equal(i.seconds, 0)
     assert_equal(i.microseconds, 10)
示例#18
0
文件: time_test.py 项目: wr41thx/dmc
    def test_float_seconds(self):
        i = TimeInterval(1.2)

        assert_equal(i.seconds, 1)
        assert_equal(i.microseconds, 200000)
示例#19
0
文件: time_test.py 项目: wr41thx/dmc
 def test_str(self):
     i = TimeInterval(hours=1, minutes=45, seconds=21, microseconds=600000)
     assert_equal(str(i), "+01:45:21.6")
示例#20
0
文件: time_test.py 项目: wr41thx/dmc
    def test_abs(self):
        i1 = TimeInterval(2.22)

        i2 = abs(i1)

        assert_equal(float(i1), 2.22)
示例#21
0
文件: time_test.py 项目: wr41thx/dmc
    def test_add(self):
        i1 = TimeInterval(1)
        i2 = TimeInterval(1)

        i3 = i1 + i2
        assert_equal(i3.seconds, 2)
示例#22
0
文件: time_test.py 项目: wr41thx/dmc
 def test_float(self):
     i = TimeInterval(4, microseconds=600000)
     assert_equal(float(i), 4.6)
示例#23
0
文件: time_test.py 项目: wr41thx/dmc
 def test_minutes(self):
     i = TimeInterval(minutes=2)
     assert_equal(i.seconds, 120)
     assert_equal(i.microseconds, 0)