Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# we are able to directly delete it from the object's __dict__.
del self.__dict__[name]
def setter(method, self, other):
if isinstance(self, type):
# if the attribute has to be set to a class object
# we cannot use ``self.__dict__[name] = other`` directly because we cannot
# modify a mappingproxy object. Thus, we have to set it in our
# proxy __dict__.
overwritten_object_handlers[(id(self), method.__name__)] = other
else:
# if the attribute has to be set to an instance object
# we are able to directly set it in the object's __dict__.
self.__dict__[name] = other
return builtins.property(
fget=method,
fset=partial(setter, method),
fdel=partial(deleter, method),
)
def assertionproperty(func):
return builtins.property(assertionmethod(func))
assert self.obj > num, msg
return True
@assertionmethod
def length_of(self, num):
if self.negative:
return self._that.len_is_not(num)
return self._that.len_is(num)
def called_with(self, *args, **kw):
self._callable_args = args
self._callable_kw = kw
return self
called = builtins.property(called_with)
@assertionmethod
def throw(self, *args, **kw):
_that = AssertionHelper(self.obj,
with_args=self._callable_args,
and_kwargs=self._callable_kw)
if self.negative:
msg = ("{0} called with args {1} and kwargs {2} should "
"not raise {3} but raised {4}")
exc = args and args[0] or Exception
try:
self.obj(*self._callable_args, **self._callable_kw)
return True
except Exception as e: