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