Last active
August 29, 2015 14:07
Revisions
-
guykisel revised this gist
Oct 15, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ # https://github.com/guykisel/robotframework-faker/issues/3 # Does not work: ${WordsList} = Words nb=10 # Works: ${WordsList} = Words nb=${10} # Libdoc introspects accurate args/kwargs def __getattr__(self, name): func = None @@ -17,6 +18,7 @@ def __getattr__(self, name): # with autocast # Works: ${WordsList} = Words nb=10 # Works: ${WordsList} = Words nb=${10} # Libdoc shows *args, **kwargs for all keywords def __getattr__(self, name): if name in _fake.__dict__.keys(): -
guykisel revised this gist
Oct 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def __getattr__(self, name): func = None if name in self._fake.__dict__.keys(): return self._fake.__dict__[name].im_func) elif name in faker.generator.Generator.__dict__.keys(): return faker.generator.Generator.__dict__[name] raise AttributeError('Non-existing keyword "{0}"'.format(name)) -
guykisel created this gist
Oct 15, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # No autocast: # https://github.com/guykisel/robotframework-faker/issues/3 # Does not work: ${WordsList} = Words nb=10 # Works: ${WordsList} = Words nb=${10} def __getattr__(self, name): func = None if name in self._fake.__dict__.keys(): return gfake.__dict__[name].im_func) elif name in faker.generator.Generator.__dict__.keys(): return faker.generator.Generator.__dict__[name] raise AttributeError('Non-existing keyword "{0}"'.format(name)) # with autocast # Works: ${WordsList} = Words nb=10 # Works: ${WordsList} = Words nb=${10} def __getattr__(self, name): if name in _fake.__dict__.keys(): return _str_vars_to_data(_fake.__dict__[name].im_func) elif name in faker.generator.Generator.__dict__.keys(): return _str_vars_to_data(faker.generator.Generator.__dict__[name]) raise AttributeError('Non-existing keyword "{0}"'.format(name)) def _str_to_data(string): try: return ast.literal_eval(str(string).strip()) except Exception: return string @decorator.decorator def _str_vars_to_data(f, *args, **kwargs): args = [_str_to_data(arg) for arg in args] kwargs = dict((arg_name, _str_to_data(arg)) for arg_name, arg in kwargs.items()) result = f(*args, **kwargs) logger.debug(result) return result