Python exceptions.AssertionError() Examples

The following are 17 code examples of exceptions.AssertionError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module exceptions , or try the search function .
Example #1
Source File: test_exceptions.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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__) 
Example #2
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetTraceForRaisesWithInvalidTrace(self):
    builder = trace_data.TraceDataBuilder()

    self.assertRaises(
        exceptions.AssertionError,
        lambda: builder.AddTraceFor(trace_data.TELEMETRY_PART,
                                    datetime.time.min)) 
Example #3
Source File: thread_pool.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
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 
Example #4
Source File: test_utils.py    From product-definition-center with MIT License 5 votes vote down vote up
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 
Example #5
Source File: python26.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_exception_message_deprecated():
    import exceptions
    x = exceptions.AssertionError()
    
    with OutputCatcher() as output:
        x.message

    expected = ""
    Assert(expected in output.stderr, output.stderr) 
Example #6
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetTraceForRaisesWithInvalidTrace(self):
    builder = trace_data.TraceDataBuilder()

    self.assertRaises(
        exceptions.AssertionError,
        lambda: builder.AddTraceFor(trace_data.TELEMETRY_PART,
                                    datetime.time.min)) 
Example #7
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetTraceForRaisesWithInvalidPart(self):
    builder = trace_data.TraceDataBuilder()

    self.assertRaises(exceptions.AssertionError,
                      lambda: builder.AddTraceFor('not_a_trace_part', {})) 
Example #8
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testInvalidTrace(self):
    with self.assertRaises(AssertionError):
      trace_data.CreateTraceDataFromRawData({'hello': 1}) 
Example #9
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetTraceForRaisesWithInvalidPart(self):
    builder = trace_data.TraceDataBuilder()

    self.assertRaises(exceptions.AssertionError,
                      lambda: builder.AddTraceFor('not_a_trace_part', {})) 
Example #10
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testInvalidTrace(self):
    with self.assertRaises(AssertionError):
      trace_data.CreateTraceDataFromRawData({'hello': 1}) 
Example #11
Source File: handlers_test.py    From gae-secure-scaffold-python with Apache License 2.0 5 votes vote down vote up
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) 
Example #12
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetTraceForRaisesWithInvalidPart(self):
    builder = trace_data.TraceDataBuilder()

    self.assertRaises(exceptions.AssertionError,
                      lambda: builder.AddTraceFor('not_a_trace_part', {})) 
Example #13
Source File: trace_data_unittest.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testInvalidTrace(self):
    with self.assertRaises(AssertionError):
      trace_data.CreateTraceDataFromRawData({'hello': 1}) 
Example #14
Source File: test_exceptions.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_raise(self):
        try:
             self.fail("Message")
        except AssertionError, e:
             self.assertEqual(e.__str__(), e.args[0]) 
Example #15
Source File: python26.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_exception_message_deprecated():
    import exceptions
    x = exceptions.AssertionError()
    
    with OutputCatcher() as output:
        x.message

    expected = ""
    Assert(expected in output.stderr, output.stderr) 
Example #16
Source File: handlers_test.py    From gae-secure-scaffold-python with Apache License 2.0 5 votes vote down vote up
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) 
Example #17
Source File: test_exceptions.py    From ironpython2 with Apache License 2.0 4 votes vote down vote up
def test_assert(self):
        try:
            self.assertTrue(False, "Failed message")
        except AssertionError, e:
            self.assertTrue(e.args[0] == "Failed message")