Exemplo n.º 1
0
    def test_status(self):
        """
        Ensure that L{statust.fromFailure} works as expected
        """
        f = self.buildFailure(TestRuntimeError, 'foo bar')

        s = status.fromFailure(f)

        self.assertTrue(status.IStatus.providedBy(s))
        self.assertEqual(s.level, 'error')
        self.assertEqual(s.code, None)
        self.assertEqual(s.description, 'foo bar')
Exemplo n.º 2
0
    def test_status(self):
        """
        Ensure that L{statust.fromFailure} works as expected
        """
        f = self.buildFailure(TestRuntimeError, 'foo bar')

        s = status.fromFailure(f)

        self.assertTrue(status.IStatus.providedBy(s))
        self.assertEqual(s.level, 'error')
        self.assertEqual(s.code, None)
        self.assertEqual(s.description, 'foo bar')
Exemplo n.º 3
0
    def test_default_code(self):
        """
        L{status.fromFailure} looks for a C{code} attribute on the exception
        instance contained in the failure. If one is not present, supplying a
        default code is allowed.
        """
        f = self.buildFailure(RuntimeError, 'spam eggs')

        self.assertFalse(hasattr(f.value, 'code'))

        s = status.fromFailure(f, 'default code')

        self.assertTrue(status.IStatus.providedBy(s))
        self.assertEqual(s.level, 'error')
        self.assertEqual(s.code, 'default code')
        self.assertEqual(s.description, 'spam eggs')
Exemplo n.º 4
0
    def test_default_code(self):
        """
        L{status.fromFailure} looks for a C{code} attribute on the exception
        instance contained in the failure. If one is not present, supplying a
        default code is allowed.
        """
        f = self.buildFailure(RuntimeError, 'spam eggs')

        self.assertFalse(hasattr(f.value, 'code'))

        s = status.fromFailure(f, 'default code')

        self.assertTrue(status.IStatus.providedBy(s))
        self.assertEqual(s.level, 'error')
        self.assertEqual(s.code, 'default code')
        self.assertEqual(s.description, 'spam eggs')