本文整理汇总了Python中exceptions.AssertionError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.AssertionError方法的具体用法?Python exceptions.AssertionError怎么用?Python exceptions.AssertionError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exceptions
的用法示例。
在下文中一共展示了exceptions.AssertionError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serializable_clionly
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def test_serializable_clionly(self):
import clr
import System
from IronPythonTest import ExceptionsTest
path = clr.GetClrType(ExceptionsTest).Assembly.Location
mbro = System.AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(path, "IronPythonTest.EngineTest")
self.assertRaises(AssertionError, mbro.Run, 'raise AssertionError')
import exceptions
for eh in dir(exceptions):
eh = getattr(exceptions, eh)
if isinstance(eh, type) and issubclass(eh, BaseException):
# unicode exceptions require more args...
if (eh.__name__ != 'UnicodeDecodeError' and
eh.__name__ != 'UnicodeEncodeError' and
eh.__name__ != 'UnicodeTranslateError'):
self.assertRaises(eh, mbro.Run, 'raise ' + eh.__name__)
示例2: testCronFailsWithoutXAppEngineCron
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testCronFailsWithoutXAppEngineCron(self):
try:
self.app.get_response('/cron', method='GET')
self.fail('Cron succeeded without X-AppEngine-Cron: true header')
except exceptions.AssertionError, e:
# webapp2 wraps the raised SecurityError during dispatch with an
# exceptions.AssertionError.
self.assertTrue(e.message.find('X-AppEngine-Cron') != -1)
示例3: testTaskFailsWithoutXAppEngineQueueName
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testTaskFailsWithoutXAppEngineQueueName(self):
try:
self.app.get_response('/task', method='GET')
self.fail('Task succeeded without X-AppEngine-QueueName header')
except exceptions.AssertionError, e:
# webapp2 wraps the raised SecurityError during dispatch with an
# exceptions.AssertionError.
self.assertTrue(e.message.find('X-AppEngine-QueueName') != -1)
示例4: test_exception_message_deprecated
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def test_exception_message_deprecated():
import exceptions
x = exceptions.AssertionError()
with OutputCatcher() as output:
x.message
expected = ""
Assert(expected in output.stderr, output.stderr)
示例5: test_raise
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def test_raise(self):
try:
self.fail("Message")
except AssertionError, e:
self.assertEqual(e.__str__(), e.args[0])
示例6: test_assert
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def test_assert(self):
try:
self.assertTrue(False, "Failed message")
except AssertionError, e:
self.assertTrue(e.args[0] == "Failed message")
示例7: testInvalidTrace
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testInvalidTrace(self):
with self.assertRaises(AssertionError):
trace_data.CreateTraceDataFromRawData({'hello': 1})
示例8: testSetTraceForRaisesWithInvalidPart
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testSetTraceForRaisesWithInvalidPart(self):
builder = trace_data.TraceDataBuilder()
self.assertRaises(exceptions.AssertionError,
lambda: builder.AddTraceFor('not_a_trace_part', {}))
示例9: testSetTraceForRaisesWithInvalidTrace
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testSetTraceForRaisesWithInvalidTrace(self):
builder = trace_data.TraceDataBuilder()
self.assertRaises(
exceptions.AssertionError,
lambda: builder.AddTraceFor(trace_data.TELEMETRY_PART,
datetime.time.min))
示例10: assertNumChanges
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def assertNumChanges(self, num_changes=[]):
"""
Check that there is expected number of changes with expected number of
changes in each. Argument should be a list containing numbers of
changes in respective changesets.
"""
changesets = models.Changeset.objects.all()
if len(changesets) != len(num_changes):
raise AssertionError('Expected %d changesets, found %d' % (len(num_changes), len(changesets)))
for i, (changeset, num) in enumerate(zip(changesets, num_changes)):
if num != changeset.change_set.count():
raise AssertionError('Wrong number of changes in change set %d, expected %d, got %d'
% (i, num, changeset.change_set.count()))
return True
示例11: successful
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def successful(self):
"""
Return whether the call completed without raising an exception.
Will raise AssertionError if the result is not ready.
"""
if not self.ready():
raise exceptions.AssertionError("Function is not ready")
res = self._q.get()
self._q.put(res)
if isinstance(res, Exception):
return False
return True