def testExplicitSize(self): result = self._func(lambda: 1024, units.Quantity('1 GiB')) self.assertEqual(result, 1073741824)
def testPercent(self): result = self._func(lambda: 1024, units.Quantity('25%')) self.assertEqual(result, 256)
does not meet the requirements described in self.syntactic_help. """ size = super(_MemorySizeParser, self).Parse(inp) if size.units != units.percent: size_byte_count = size.to(units.byte).magnitude if size_byte_count != int(size_byte_count): raise ValueError( 'Expression {0!r} parses to memory size {1!r}, which is not ' 'convertible to an integer number of bytes.'.format( inp, str(size))) return size _MEMORY_SIZE_PARSER = _MemorySizeParser() _UNITS_SERIALIZER = flag_util.UnitsSerializer() _DEFAULT_MEMORY_SIZE = units.Quantity('256 MiB') _DEFAULT_STRIDE_SIZE = units.Quantity('256 bytes') def _DefineMemorySizeFlag(name, default, help, flag_values=FLAGS, **kwargs): flags.DEFINE(_MEMORY_SIZE_PARSER, name, default, help, flag_values, _UNITS_SERIALIZER, **kwargs) flags.DEFINE_enum( 'multichase_chase_type', 'simple', sorted(_CHASES), 'Chase type to use when executing multichase. Passed to multichase via its ' '-c flag.') flags.DEFINE_integer( 'multichase_chase_arg', 1, 'Argument to refine the chase type specified with --multichase_chase_type. '