def test_filesize(self): self.assertEqual(filesize('2000'), 2000) self.assertEqual(filesize('11KB'), 1024 * 11) self.assertEqual(filesize('12MB'), 1024 * 1024 * 12) self.assertEqual(filesize('1KB'), 1024) self.assertEqual(filesize('1MB'), 1024 * 1024) self.assertEqual(filesize('2KB'), 1024 * 2)
def test_filesize_error(self): with self.assertRaises(ValueError): filesize('FOO') with self.assertRaises(ValueError): filesize('0.00000')