Esempio n. 1
0
def _check_async_timer():
    with AsyncTimer() as t:
        results = yield [_slow_task.asynq(0.1), _timed_slow_task.asynq(0.1),
                         _slow_task.asynq(0.1), _timed_slow_task.asynq(0.1)]
        assert_eq(0, results[0])
        assert_eq(105000, results[1], tolerance=5000)
        assert_eq(0, results[0])
        assert_eq(105000, results[3], tolerance=5000)

    assert_eq(210000, sum(results), tolerance=10000)
    assert_eq(410000, t.total_time, tolerance=10000)
    assert_gt(t.total_time, sum(results))
Esempio n. 2
0
 def handler1(*args):
     assert_gt(len(args), 0)
     calls.append('handler1%s' % str(args))
Esempio n. 3
0
def test_assert_ordering():
    # ints
    assert_gt(2, 1)
    with AssertRaises(AssertionError):
        assert_gt(1, 1)
    with AssertRaises(AssertionError):
        assert_gt(0, 1)

    assert_ge(2, 1)
    assert_ge(1, 1)
    with AssertRaises(AssertionError):
        assert_ge(0, 1)

    with AssertRaises(AssertionError):
        assert_lt(2, 1)
    with AssertRaises(AssertionError):
        assert_lt(1, 1)
    assert_lt(0, 1)

    with AssertRaises(AssertionError):
        assert_le(2, 1)
    assert_le(1, 1)
    assert_lt(0, 1)

    # floats (tolerance isn't supported)
    assert_gt(2.5, 1.5)
    with AssertRaises(AssertionError):
        assert_gt(1.5, 1.5)
    with AssertRaises(AssertionError):
        assert_gt(0.5, 1.5)

    assert_ge(2.5, 1.5)
    assert_ge(1.5, 1.5)
    with AssertRaises(AssertionError):
        assert_ge(0.5, 1.5)

    with AssertRaises(AssertionError):
        assert_lt(2.5, 1.5)
    with AssertRaises(AssertionError):
        assert_lt(1.5, 1.5)
    assert_lt(0.5, 1.5)

    with AssertRaises(AssertionError):
        assert_le(2.5, 1.5)
    assert_le(1.5, 1.5)
    assert_lt(0.5, 1.5)

    # strings
    assert_gt("c", "b")
    with AssertRaises(AssertionError):
        assert_gt("b", "b")
    with AssertRaises(AssertionError):
        assert_gt("a", "b")

    assert_ge("c", "b")
    assert_ge("b", "b")
    with AssertRaises(AssertionError):
        assert_ge("a", "b")

    with AssertRaises(AssertionError):
        assert_lt("c", "b")
    with AssertRaises(AssertionError):
        assert_lt("b", "b")
    assert_lt("a", "b")

    with AssertRaises(AssertionError):
        assert_le("c", "b")
    assert_le("b", "b")
    assert_lt("a", "b")