本文整理汇总了Python中sure.old.AssertionHelper.len_is_not方法的典型用法代码示例。如果您正苦于以下问题:Python AssertionHelper.len_is_not方法的具体用法?Python AssertionHelper.len_is_not怎么用?Python AssertionHelper.len_is_not使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sure.old.AssertionHelper
的用法示例。
在下文中一共展示了AssertionHelper.len_is_not方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AssertionBuilder
# 需要导入模块: from sure.old import AssertionHelper [as 别名]
# 或者: from sure.old.AssertionHelper import len_is_not [as 别名]
#.........这里部分代码省略.........
assert not self.obj <= dest, msg
else:
msg = "expected `{0}` to be lower than or equal to `{1}`".format(
self.obj, dest)
assert self.obj <= dest, msg
return True
@assertionmethod
def below(self, num):
if self.negative:
msg = "{0} should not be below {1}".format(self.obj, num)
assert not self.obj < num, msg
else:
msg = "{0} should be below {1}".format(self.obj, num)
assert self.obj < num, msg
return True
@assertionmethod
def above(self, num):
if self.negative:
msg = "{0} should not be above {1}".format(self.obj, num)
assert not self.obj > num, msg
else:
msg = "{0} should be above {1}".format(self.obj, num)
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:
err = msg.format(
self.obj,
self._that._callable_args,
self._that._callable_kw,
exc,
e,
)
示例2: AssertionBuilder
# 需要导入模块: from sure.old import AssertionHelper [as 别名]
# 或者: from sure.old.AssertionHelper import len_is_not [as 别名]
#.........这里部分代码省略.........
assert not self.obj >= dest, msg
else:
msg = u"expected `{0}` to be greater than or equal to `{1}`".format(
self.obj, dest)
assert self.obj >= dest, msg
return True
@assertionmethod
def lower_than(self, dest):
if self.negative:
msg = u"expected `{0}` to not be lower than `{1}`".format(
self.obj, dest)
assert not self.obj < dest, msg
else:
msg = u"expected `{0}` to be lower than `{1}`".format(
self.obj, dest)
assert self.obj < dest, msg
return True
@assertionmethod
def lower_than_or_equal_to(self, dest):
if self.negative:
msg = u"expected `{0}` to not be lower than or equal to `{1}`".format(
self.obj, dest)
assert not self.obj <= dest, msg
else:
msg = u"expected `{0}` to be lower than or equal to `{1}`".format(
self.obj, dest)
assert self.obj <= dest, msg
return True
@assertionmethod
def below(self, num):
if self.negative:
msg = u"{0} should not be below {1}".format(self.obj, num)
assert not self.obj < num, msg
else:
msg = u"{0} should be below {1}".format(self.obj, num)
assert self.obj < num, msg
return True
@assertionmethod
def above(self, num):
if self.negative:
msg = u"{0} should not be above {1}".format(self.obj, num)
assert not self.obj > num, msg
else:
msg = u"{0} should be above {1}".format(self.obj, num)
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)
@assertionmethod
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 = (u"{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, e:
err = msg.format(
self.obj,
self._that._callable_args,
self._that._callable_kw,
exc,
e,
)
raise AssertionError(err)
return _that.raises(*args, **kw)
示例3: AssertionBuilder
# 需要导入模块: from sure.old import AssertionHelper [as 别名]
# 或者: from sure.old.AssertionHelper import len_is_not [as 别名]
#.........这里部分代码省略.........
assert not self.obj <= dest, msg
else:
msg = "expected `{0}` to be lower than or equal to `{1}`".format(self.obj, dest)
assert self.obj <= dest, msg
return True
@assertionmethod
def below(self, num):
if self.negative:
msg = "{0} should not be below {1}".format(self.obj, num)
assert not self.obj < num, msg
else:
msg = "{0} should be below {1}".format(self.obj, num)
assert self.obj < num, msg
return True
@assertionmethod
def above(self, num):
if self.negative:
msg = "{0} should not be above {1}".format(self.obj, num)
assert not self.obj > num, msg
else:
msg = "{0} should be above {1}".format(self.obj, num)
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)
@assertionmethod
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:
err = msg.format(self.obj, self._that._callable_args, self._that._callable_kw, exc, e)
raise AssertionError(err)
return _that.raises(*args, **kw)
@assertionmethod
def return_value(self, value):
return_value = self.obj(*self._callable_args, **self._callable_kw)
return this(return_value).should.equal(value)