Beispiel #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')
Beispiel #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')
Beispiel #3
0
def test_memstr_to_bytes_exception(text, exception, regex):
    with raises(exception) as excinfo:
        memstr_to_bytes(text)
    assert excinfo.match(regex)
Beispiel #4
0
def test_memstr_to_bytes(text, value):
    assert memstr_to_bytes(text) == value
Beispiel #5
0
def test_memstr_to_bytes_exception(text, exception, regex):
    with raises(exception) as excinfo:
        memstr_to_bytes(text)
    assert excinfo.match(regex)
Beispiel #6
0
def test_memstr_to_bytes(text, value):
    assert memstr_to_bytes(text) == value