本文整理汇总了Python中testify.assert_not_reached函数的典型用法代码示例。如果您正苦于以下问题:Python assert_not_reached函数的具体用法?Python assert_not_reached怎么用?Python assert_not_reached使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_not_reached函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_all_fds_cleaned_up
def test_all_fds_cleaned_up(self):
initial_open_fds = get_open_fds()
pool = vimap.pool.fork_identical(basic_worker, num_workers=1)
after_fork_open_fds = get_open_fds()
list(pool.imap([1, 2, 3]).zip_in_out())
after_finish_open_fds = get_open_fds()
# Check that some FDs were opened after forking
after_fork = difference_open_fds(initial_open_fds,
after_fork_open_fds)
# T.assert_equal(after_fork['closed'], [])
T.assert_gte(len(after_fork['opened']),
2) # should have at least 3 open fds
# All opened files should be FIFOs
if not all(info.modes == ['fifo'] for info in
after_fork['opened'].values()):
print("Infos: {0}".format(after_fork['opened']))
T.assert_not_reached("Some infos are not FIFOs")
after_cleanup = difference_open_fds(after_fork_open_fds,
after_finish_open_fds)
T.assert_gte(len(after_cleanup['closed']), 2)
left_around = difference_open_fds(initial_open_fds,
after_finish_open_fds)
if len(left_around['opened']) != 0:
queue_fds_left_around = dict(
item for item in self.queue_fds.items() if
item[0] in left_around['opened'])
print(
"Queue FDs left around: {0}".format(queue_fds_left_around))
T.assert_equal(len(left_around['opened']), 0)
开发者ID:saksenad,项目名称:vimap,代码行数:32,代码来源:closes_fds_test.py
示例2: test_fails_when_exception_is_not_raised
def test_fails_when_exception_is_not_raised(self):
raises_nothing = lambda: None
try:
assertions.assert_raises(ValueError, raises_nothing)
except AssertionError:
pass
else:
assert_not_reached('AssertionError should have been raised')
开发者ID:sumeet,项目名称:Testify,代码行数:8,代码来源:assertions_test.py
示例3: test_fails_when_wrong_exception_is_raised
def test_fails_when_wrong_exception_is_raised(self):
def raises_value_error():
raise ValueError
try:
assertions.assert_raises(MyException, raises_value_error)
except ValueError:
pass
else:
assert_not_reached('ValueError should have been raised')
开发者ID:sumeet,项目名称:Testify,代码行数:9,代码来源:assertions_test.py
示例4: test_fails_when_exception_does_not_contains_all_strings
def test_fails_when_exception_does_not_contains_all_strings(self):
def raises_value_error():
raise ValueError('abc xyz')
try:
assertions.assert_raises_and_contains(ValueError, ['ABC', '123'], raises_value_error)
except AssertionError:
pass
else:
assert_not_reached('AssertionError should have been raised')
开发者ID:farshidce,项目名称:Testify,代码行数:9,代码来源:assertions_test.py
示例5: test_fails_when_exception_is_not_raised
def test_fails_when_exception_is_not_raised(self):
def raises_nothing():
pass
try:
assertions.assert_raises_and_contains(ValueError, 'abc', raises_nothing)
except AssertionError:
pass
else:
assert_not_reached('AssertionError should have been raised')
开发者ID:Yelp,项目名称:Testify,代码行数:9,代码来源:assertions_test.py
示例6: test_message_on_fail
def test_message_on_fail(self):
superset = {'one': 1, 'two': 2, 'three': 3}
subset = {'one': 2, 'two':2}
expected = "expected [subset has:{'one': 2}, superset has:{'one': 1}]"
try:
assert_dict_subset(subset, superset)
except AssertionError as e:
assert_equal(expected, e.args[0])
else:
assert_not_reached('AssertionError should have been raised')
开发者ID:pyarnold,项目名称:Testify,代码行数:11,代码来源:assertions_test.py
示例7: no_warnings
def no_warnings():
'''Make vimap.exception_handling.print_warning fail tests.'''
import testify as T # in case you're not using testify
return mock.patch.object(
vimap.exception_handling,
'print_warning',
lambda *args, **kwargs: T.assert_not_reached())
开发者ID:ny2ko,项目名称:vimap,代码行数:8,代码来源:testing.py
示例8: wrapper
def wrapper(method):
def on_timeout(d):
e = defer.TimeoutError("(%s) still running at %s secs" %
(method.__name__, timeout))
f = failure.Failure(e)
try:
d.errback(f)
except defer.AlreadyCalledError:
# if the deferred has been called already but the *back chain
# is still unfinished, crash the reactor and report timeout
# error ourself.
reactor.crash()
raise
@functools.wraps(method)
def run_defer(*args, **kwargs):
deferred = defer.maybeDeferred(method, *args, **kwargs)
call = reactor.callLater(timeout, on_timeout, deferred)
deferred.addBoth(lambda x: call.active() and call.cancel() or x)
found_error = False
try:
wait_for_deferred(deferred)
except TwistedFailureError, e:
if assert_raises:
d_fail = e.args[0]
if issubclass(d_fail.type, assert_raises):
found_error = True
else:
raise
if assert_raises and not found_error:
assert_not_reached("No exception was raised (expected %s)" %
assert_raises)
return None
开发者ID:bchess,项目名称:Tron,代码行数:38,代码来源:testingutils.py
示例9: test_message_on_fail
superset = {'one': 1, 'two': 2, 'three': 3}
subset = {'one': 2}
assertions.assert_raises(AssertionError, assert_dict_subset, superset, subset)
def test_message_on_fail(self):
superset = {'one': 1, 'two': 2, 'three': 3}
subset = {'one': 2, 'two':2}
expected = "expected [subset has:{'one': 2}, superset has:{'one': 1}]"
try:
assert_dict_subset(subset, superset)
except AssertionError, e:
assert_equal(expected, e.args[0])
else:
assert_not_reached('AssertionError should have been raised')
class AssertEmptyTestCase(TestCase):
def test_passes_on_empty_list(self):
"""Test that assert_empty passes on an empty list."""
assertions.assert_empty([])
def test_passes_on_unyielding_generator(self):
"""Test that assert_empty passes on an 'empty' generator."""
def yield_nothing():
if False:
yield 0
assertions.assert_empty(yield_nothing())
开发者ID:farshidce,项目名称:Testify,代码行数:30,代码来源:assertions_test.py
示例10: get_ec
def get_ec(self):
try:
raise self.err
except:
return exception_handling.ExceptionContext.current()
testify.assert_not_reached()
开发者ID:saksenad,项目名称:vimap,代码行数:6,代码来源:exception_handling_test.py
注:本文中的testify.assert_not_reached函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论