コード例 #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
ファイル: test_output.py プロジェクト: molinav/gsync
    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
ファイル: test_output.py プロジェクト: molinav/gsync
    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())