How to use make_safe_property method in Sure

Best Python code snippet using sure_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...721those = AssertionBuilder('those')722expect = AssertionBuilder('expect')723allows_new_syntax = not os.getenv('SURE_DISABLE_NEW_SYNTAX')724if is_cpython and allows_new_syntax:725 def make_safe_property(method, name, should_be_property=True):726 if not should_be_property:727 return method(None)728 def deleter(self, *args, **kw):729 pass730 def setter(self, other):731 pass732 return builtins.property(733 fget=method,734 fset=setter,735 fdel=deleter,736 )737 def positive_assertion(name, prop=True):738 def method(self):739 builder = AssertionBuilder(name, negative=False)740 instance = builder(self)741 callable_args = getattr(self, '_callable_args', ())742 if callable_args:743 instance._callable_args = callable_args744 callable_kw = getattr(self, '_callable_kw', {})745 if callable_kw:746 instance._callable_kw = callable_kw747 return instance748 method.__name__ = str(name)749 return make_safe_property(method, name, prop)750 def negative_assertion(name, prop=True):751 def method(self):752 builder = AssertionBuilder(name, negative=True)753 instance = builder(self)754 callable_args = getattr(self, '_callable_args', ())755 if callable_args:756 instance._callable_args = callable_args757 callable_kw = getattr(self, '_callable_kw', {})758 if callable_kw:759 instance._callable_kw = callable_kw760 return instance761 method.__name__ = str(name)762 return make_safe_property(method, name, prop)763 object_handler = patchable_builtin(object)764 # None does not have a tp_dict associated to its PyObject, so this765 # is the only way we could make it work like we expected.766 none = patchable_builtin(None.__class__)767 for name in POSITIVES:768 object_handler[name] = positive_assertion(name)769 none[name] = positive_assertion(name, False)770 for name in NEGATIVES:771 object_handler[name] = negative_assertion(name)772 none[name] = negative_assertion(name, False)773old_dir = dir774if allows_new_syntax:775 @wraps(builtins.dir)776 def _new_dir(obj=None):...

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 Sure 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