示例#1
0
def test_wround():
    # Invalid input formats.
    assert_raises(TypeError, wround, None)
    assert_raises(TypeError, wround, 'yadayada')
    assert_raises(TypeError, wround, '0')

    # Integers as well as floats should work.
    assert_almost_equal(wround(5, 2), 5)
    assert_almost_equal(wround(5.001, 2), 5)
示例#2
0
def test_wround():
    # Invalid input formats.
    assert_raises(TypeError, wround, None)
    assert_raises(TypeError, wround, "yadayada")
    assert_raises(TypeError, wround, "0")

    # Integers as well as floats should work.
    assert_almost_equal(wround(5, 2), 5)
    assert_almost_equal(wround(5.001, 2), 5)

    # Invalid method
    assert_raises(FilterArgumentError, wround, 0, 2, "new")
    assert_raises(FilterArgumentError, wround, 0, -2)

    assert_almost_equal(wround(4.1, 1, "floor"), 4.1)
    eq_(wround(4.1, method="floor"), 4)