Пример #1
0
    def test_exception_as_string(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        import re
        pat = re.compile(
            r'''^DEBUG: 'Test exception': ''',
            re.M | re.S
        )

        try:
            raise Exception("Test exception")
        except Exception, e:
            channel.exception(str(e))
Пример #2
0
    def test_exception_as_object(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        import re
        pat = re.compile(
            r'''^DEBUG: Exception\('Test exception',\): ''',
            re.M | re.S
        )

        try:
            raise Exception("Test exception")
        except Exception, e:
            channel.exception(e)
Пример #3
0
    def test_exception_as_string(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        import re
        pat = re.compile(r'''^DEBUG: 'Test exception': ''', re.M | re.S)

        try:
            raise Exception("Test exception")
        except Exception as e:
            channel.exception(str(e))

        self.assertIsNotNone(pat.search(sys.stdout.getvalue()))
        self.assertEqual("", sys.stderr.getvalue())
Пример #4
0
    def test_stack(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        channel.stack()

        import re
        pat = re.compile(
            r'^DEBUG: BEGIN STACK TRACE\n' \
            r'.*\n' \
            r'DEBUG: END STACK TRACE\n$',
            re.M | re.S
        )
        self.assertIsNotNone(pat.search(sys.stdout.getvalue()))
        self.assertEqual("", sys.stderr.getvalue())
Пример #5
0
    def test_exception_as_custom_string(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        custom_string = "This is a custom string"

        import re
        pat = re.compile(
            r'''^DEBUG: %s: ''' % repr(custom_string),
            re.M | re.S
        )

        try:
            raise Exception("Test exception")
        except Exception, e:
            channel.exception(custom_string)
Пример #6
0
    def test_exception_as_custom_string(self):
        channel = Debug()
        channel.enable()
        self.assertTrue(channel.enabled())

        custom_string = "This is a custom string"

        import re
        pat = re.compile(r'''^DEBUG: %s: ''' % repr(custom_string),
                         re.M | re.S)

        try:
            raise Exception("Test exception")
        except Exception as e:
            channel.exception(custom_string)

        self.assertIsNotNone(pat.search(sys.stdout.getvalue()))
        self.assertEqual("", sys.stderr.getvalue())