def test_parse_decimal(self): self.assertEqual(Information.parse('1.4 GB'), Information(10**9 * 1.4 * 8, Information.BITS))
def test_parse_integer(self): self.assertEqual(Information.parse('123 YiB'), Information(2**80 * 123 * 8, Information.BITS))
def test_parse_invalid_number(self): with self.assertRaises(ValueError): Information.parse('1.2.3 TiB')
def test_parse_invalid_unit(self): with self.assertRaises(ValueError): Information.parse('1 TiBoo')
def test_parse_rubbish(self): with self.assertRaises(ValueError): Information.parse('rubbish')