Exemplo n.º 1
0
def test_memstr_to_bytes():
    for text, value in zip(
        ('80G', '1.4M', '120M', '53K'),
        (80 * 1024**3, int(1.4 * 1024**2), 120 * 1024**2, 53 * 1024)):
        yield nose.tools.assert_equal, memstr_to_bytes(text), value

    nose.tools.assert_raises(ValueError, memstr_to_bytes, 'foobar')
Exemplo n.º 2
0
def test_memstr_to_bytes():
    for text, value in zip(('80G', '1.4M', '120M', '53K'),
                           (80 * 1024 ** 3, int(1.4 * 1024 ** 2),
                            120 * 1024 ** 2, 53 * 1024)):
        yield nose.tools.assert_equal, memstr_to_bytes(text), value

    nose.tools.assert_raises(ValueError, memstr_to_bytes, 'foobar')
Exemplo n.º 3
0
def test_memstr_to_bytes_exception(text, exception, regex):
    with raises(exception) as excinfo:
        memstr_to_bytes(text)
    assert excinfo.match(regex)
Exemplo n.º 4
0
def test_memstr_to_bytes(text, value):
    assert memstr_to_bytes(text) == value
Exemplo n.º 5
0
def test_memstr_to_bytes_exception(text, exception, regex):
    with raises(exception) as excinfo:
        memstr_to_bytes(text)
    assert excinfo.match(regex)
Exemplo n.º 6
0
def test_memstr_to_bytes(text, value):
    assert memstr_to_bytes(text) == value