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))
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)
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())
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())
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)
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())