def _get_runnable_dry_run_keywords(self, context, args): keywords = Keywords([]) for keyword in self._get_dry_run_keywords(args): if contains_var(keyword.name): continue keywords.add_keyword(keyword) return keywords
def coerce(self, argument, dryrun=False): if not is_string(argument) \ or (dryrun and contains_var(argument)): return argument try: return self._coerce(argument) except ValueError: raise ValueError('Argument at position %d cannot be coerced to %s.' % (self._position, self._name))
def _convert(self, name, value): type_, explicit_type = self._get_type(name, value) if type_ is None or (self._dry_run and contains_var(value, identifiers='$@&%')): return value converter = TypeConverter.converter_for(type_) if converter is None: return value return converter.convert(name, value, explicit_type)
def coerce(self, argument, dryrun=False): if not isinstance(argument, string_types) \ or (dryrun and contains_var(argument)): return argument try: return self._coerce(argument) except ValueError: raise ValueError('Argument at position %d cannot be coerced to %s.' % (self._position, self._name))
def test_contains_var(self): for ok in SCALARS + LISTS + ['hi ${var}', '@{x}y', '${no ${yes}!']: assert contains_var(ok) for nok in [None, 42, unittest, '', 'nothing', '${no', '*{not}']: assert not contains_var(nok)
def test_contains_var(self): for ok in SCALARS + LISTS + ["hi ${var}", "@{x}y", "${no ${yes}!"]: assert contains_var(ok) for nok in [None, 42, unittest, "", "nothing", "${no", "*{not}"]: assert not contains_var(nok)