当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.AssertionError方法代码示例

本文整理汇总了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__) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_exceptions.py

示例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) 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:10,代码来源:handlers_test.py

示例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) 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:10,代码来源:handlers_test.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:python26.py

示例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]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_exceptions.py

示例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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_exceptions.py

示例7: testInvalidTrace

# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AssertionError [as 别名]
def testInvalidTrace(self):
    with self.assertRaises(AssertionError):
      trace_data.CreateTraceDataFromRawData({'hello': 1}) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:5,代码来源:trace_data_unittest.py

示例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', {})) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:7,代码来源:trace_data_unittest.py

示例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)) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:9,代码来源:trace_data_unittest.py

示例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 
开发者ID:product-definition-center,项目名称:product-definition-center,代码行数:16,代码来源:test_utils.py

示例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 
开发者ID:splunk,项目名称:SA-ctf_scoreboard,代码行数:16,代码来源:thread_pool.py


注:本文中的exceptions.AssertionError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。