How to use resolve_underlying_function method in Slash

Best Python code snippet using slash

python.py

Source:python.py Github

copy

Full Screen

...84 except Exception: # pylint: disable=broad-except85 exc_info = sys.exc_info()86 if exc_info is not None:87 reraise(*exc_info)88def resolve_underlying_function(thing):89 """Gets the underlying (real) function for functions, wrapped functions, methods, etc.90 Returns the same object for things that are not functions91 """92 while True:93 wrapped = getattr(thing, "__func__", None) or getattr(thing, "__wrapped__", None) or getattr(thing, "__wraps__", None)94 if wrapped is None:95 break96 thing = wrapped97 return thing98def reraise(tp, value, tb=None):99 # A hacky way to check, whether we have a TracebackProxy here. Can't check directly, as100 # it would lead to circular import.101 if value.__traceback__ is not tb:102 if not isinstance(tb, TracebackType):...

Full Screen

Full Screen

requirements.py

Source:requirements.py Github

copy

Full Screen

...14 reqs.append(req)15 return func_or_class16 return decorator17def _get_requirements_list(thing, create=True):18 thing = resolve_underlying_function(thing)19 existing = getattr(thing, _SLASH_REQUIRES_KEY_NAME, None)20 key = id(thing)21 if existing is None or key != existing[0]:22 new_reqs = (key, [] if existing is None else existing[1][:])23 if create:24 setattr(thing, _SLASH_REQUIRES_KEY_NAME, new_reqs)25 assert thing.__slash_requirements__ is new_reqs26 returned = new_reqs[1]27 else:28 returned = existing[1]29 return returned30def get_requirements(test):31 return list(_get_requirements_list(test, create=False))32class Requirement(object):...

Full Screen

Full Screen

test_python_utils.py

Source:test_python_utils.py Github

copy

Full Screen

...32 class Blap(object):33 @decorator34 def method(self):35 pass36 resolved = resolve_underlying_function(Blap.method)37 assert resolved is resolve_underlying_function(Blap.method) # stable38 assert not hasattr(resolved, '__func__')39 assert resolved.__name__ == 'method'40@pytest.mark.parametrize('thing', [object(), object, None, 2, "string"])41def test_resolve_underlying_function_method_no_op(thing):42 assert resolve_underlying_function(thing) is thing43def _example_decorator(func):44 @wraps(func)45 def new_func():46 pass47 return new_func48def test_resolve_underlying_decorator_regular_func():49 def orig():50 pass51 decorated = _example_decorator(orig)52 assert resolve_underlying_function(decorated) is orig53def test_resolve_underlying_decorator_method():54 class Blap(object):55 def orig(self):56 pass57 decorated = _example_decorator(orig)58 assert resolve_underlying_function(Blap.decorated) is resolve_underlying_function(Blap.orig)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful