def testInvalidInput(self): """ Test that parsing handles invalid input correctly """ self.assertEqual(misc.parseHumanReadableSize("T"), 0) self.assertEqual(misc.parseHumanReadableSize("TNT"), 0) self.assertRaises(AttributeError, misc.parseHumanReadableSize, 5) self.assertEqual(misc.parseHumanReadableSize("4.3T"), 0)
def testValidInput(self): """ Test that the method parses size correctly if given correct input. """ for i in range(1, 1000): for schar, power in [("T", 40), ("G", 30), ("M", 20), ("K", 10)]: expected = misc.parseHumanReadableSize("%d%s" % (i, schar)) self.assertEqual(expected, (2**power) * i)
def testValidInput(self): """ Test that the method parses size correctly if given correct input. """ for i in range(1, 1000): for schar, power in [("T", 40), ("G", 30), ("M", 20), ("K", 10)]: expected = misc.parseHumanReadableSize("%d%s" % (i, schar)) self.assertEqual(expected, (2 ** power) * i)