diff --git a/better_exceptions/log.py b/better_exceptions/log.py index 517ef7b..66cf7d6 100644 --- a/better_exceptions/log.py +++ b/better_exceptions/log.py @@ -2,7 +2,7 @@ import sys -from logging import Logger, StreamHandler +from logging import Logger, StreamHandler, FileHandler def patch(): @@ -14,7 +14,8 @@ def patch(): if hasattr(logging, '_defaultFormatter'): logging._defaultFormatter.format_exception = logging_format_exception - patchables = [handler() for handler in logging._handlerList if isinstance(handler(), StreamHandler)] + patchables = [handler() for handler in logging._handlerList if isinstance(handler(), StreamHandler) + if not isinstance(handler(), FileHandler)] patchables = [handler for handler in patchables if handler.stream == sys.stderr] patchables = [handler for handler in patchables if handler.formatter is not None] for handler in patchables: diff --git a/test/output/python2-dumb-UTF-8-color.out b/test/output/python2-dumb-UTF-8-color.out index 7a93a1e..47978ea 100644 --- a/test/output/python2-dumb-UTF-8-color.out +++ b/test/output/python2-dumb-UTF-8-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-dumb-UTF-8-nocolor.out b/test/output/python2-dumb-UTF-8-nocolor.out index cbb5426..28c1d99 100644 --- a/test/output/python2-dumb-UTF-8-nocolor.out +++ b/test/output/python2-dumb-UTF-8-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-dumb-ascii-color.out b/test/output/python2-dumb-ascii-color.out index b8e8a79..1793604 100644 --- a/test/output/python2-dumb-ascii-color.out +++ b/test/output/python2-dumb-ascii-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-dumb-ascii-nocolor.out b/test/output/python2-dumb-ascii-nocolor.out index 2c418fc..831cbfb 100644 --- a/test/output/python2-dumb-ascii-nocolor.out +++ b/test/output/python2-dumb-ascii-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-vt100-UTF-8-color.out b/test/output/python2-vt100-UTF-8-color.out index 7a93a1e..47978ea 100644 --- a/test/output/python2-vt100-UTF-8-color.out +++ b/test/output/python2-vt100-UTF-8-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-vt100-UTF-8-nocolor.out b/test/output/python2-vt100-UTF-8-nocolor.out index fcb7f6c..5fa47fa 100644 --- a/test/output/python2-vt100-UTF-8-nocolor.out +++ b/test/output/python2-vt100-UTF-8-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-vt100-ascii-color.out b/test/output/python2-vt100-ascii-color.out index b8e8a79..1793604 100644 --- a/test/output/python2-vt100-ascii-color.out +++ b/test/output/python2-vt100-ascii-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-vt100-ascii-nocolor.out b/test/output/python2-vt100-ascii-nocolor.out index bbd5bb9..c66aa99 100644 --- a/test/output/python2-vt100-ascii-nocolor.out +++ b/test/output/python2-vt100-ascii-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-xterm-UTF-8-color.out b/test/output/python2-xterm-UTF-8-color.out index 7a93a1e..47978ea 100644 --- a/test/output/python2-xterm-UTF-8-color.out +++ b/test/output/python2-xterm-UTF-8-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-xterm-UTF-8-nocolor.out b/test/output/python2-xterm-UTF-8-nocolor.out index fcb7f6c..5fa47fa 100644 --- a/test/output/python2-xterm-UTF-8-nocolor.out +++ b/test/output/python2-xterm-UTF-8-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + └ + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + └ 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-xterm-ascii-color.out b/test/output/python2-xterm-ascii-color.out index b8e8a79..1793604 100644 --- a/test/output/python2-xterm-ascii-color.out +++ b/test/output/python2-xterm-ascii-color.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + ->  + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +  -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python2-xterm-ascii-nocolor.out b/test/output/python2-xterm-ascii-nocolor.out index bbd5bb9..c66aa99 100644 --- a/test/output/python2-xterm-ascii-nocolor.out +++ b/test/output/python2-xterm-ascii-nocolor.out @@ -219,3 +219,32 @@ SyntaxError: invalid syntax +python2 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception + +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + -> + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 + -> 52 +AssertionError: assert baz == 90 + + + + diff --git a/test/output/python3-dumb-UTF-8-color.out b/test/output/python3-dumb-UTF-8-color.out index a810090..3647db9 100644 --- a/test/output/python3-dumb-UTF-8-color.out +++ b/test/output/python3-dumb-UTF-8-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-dumb-UTF-8-nocolor.out b/test/output/python3-dumb-UTF-8-nocolor.out index 6475333..b5689e2 100644 --- a/test/output/python3-dumb-UTF-8-nocolor.out +++ b/test/output/python3-dumb-UTF-8-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-dumb-ascii-color.out b/test/output/python3-dumb-ascii-color.out index a7f7052..bda9b5a 100644 --- a/test/output/python3-dumb-ascii-color.out +++ b/test/output/python3-dumb-ascii-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-dumb-ascii-nocolor.out b/test/output/python3-dumb-ascii-nocolor.out index a6a1d42..ea7a7b1 100644 --- a/test/output/python3-dumb-ascii-nocolor.out +++ b/test/output/python3-dumb-ascii-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-vt100-UTF-8-color.out b/test/output/python3-vt100-UTF-8-color.out index a810090..3647db9 100644 --- a/test/output/python3-vt100-UTF-8-color.out +++ b/test/output/python3-vt100-UTF-8-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-vt100-UTF-8-nocolor.out b/test/output/python3-vt100-UTF-8-nocolor.out index f3d4f3a..a92f703 100644 --- a/test/output/python3-vt100-UTF-8-nocolor.out +++ b/test/output/python3-vt100-UTF-8-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-vt100-ascii-color.out b/test/output/python3-vt100-ascii-color.out index a7f7052..bda9b5a 100644 --- a/test/output/python3-vt100-ascii-color.out +++ b/test/output/python3-vt100-ascii-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-vt100-ascii-nocolor.out b/test/output/python3-vt100-ascii-nocolor.out index dab2f60..0030922 100644 --- a/test/output/python3-vt100-ascii-nocolor.out +++ b/test/output/python3-vt100-ascii-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-xterm-UTF-8-color.out b/test/output/python3-xterm-UTF-8-color.out index a810090..3647db9 100644 --- a/test/output/python3-xterm-UTF-8-color.out +++ b/test/output/python3-xterm-UTF-8-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-xterm-UTF-8-nocolor.out b/test/output/python3-xterm-UTF-8-nocolor.out index f3d4f3a..a92f703 100644 --- a/test/output/python3-xterm-UTF-8-nocolor.out +++ b/test/output/python3-xterm-UTF-8-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-xterm-ascii-color.out b/test/output/python3-xterm-ascii-color.out index a7f7052..bda9b5a 100644 --- a/test/output/python3-xterm-ascii-color.out +++ b/test/output/python3-xterm-ascii-color.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/output/python3-xterm-ascii-nocolor.out b/test/output/python3-xterm-ascii-nocolor.out index dab2f60..0030922 100644 --- a/test/output/python3-xterm-ascii-nocolor.out +++ b/test/output/python3-xterm-ascii-nocolor.out @@ -209,6 +209,29 @@ SyntaxError: invalid syntax +python3 test/test_file_without_colors.py + + +INFO:__main__:Hello +INFO:__main__:Hello +NoneType: None +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 36, in bar3 + raise Exception('this is a test exception') +Exception: this is a test exception +ERROR:__main__:callback failed +Traceback (most recent call last): + File "test/test_file_without_colors.py", line 19, in foo + cb() + File "test/test_file_without_colors.py", line 41, in bar4 + assert baz == 90 +AssertionError + + + python3 test/test_chaining.py diff --git a/test/test_file_without_colors.py b/test/test_file_without_colors.py new file mode 100644 index 0000000..c6cf8f9 --- /dev/null +++ b/test/test_file_without_colors.py @@ -0,0 +1,53 @@ +import better_exceptions +import logging +import sys + +better_exceptions.hook() +file_handler = logging.FileHandler(filename='example.log') +stream_handler = logging.StreamHandler(sys.stdout) +logging.basicConfig(level=logging.DEBUG, handlers=[file_handler, stream_handler]) + +logger = logging.getLogger(__name__) + +logging.raiseExceptions = True + +qux = 15 + +def foo(cb): + qix = 20 + try: + cb() + except: + logger.exception('callback failed') + + +def bar1(): + baz = 80.5 + logger.info('Hello') + + +def bar2(): + baz = 890.50 + logger.info('Hello', exc_info=True) + + +def bar3(): + baz = 600.524 + raise Exception('this is a test exception') + + +def bar4(): + baz = 52 + assert baz == 90 + + +FNS = [ + bar1, + bar2, + bar3, + bar4 +] + + +for fn in FNS: + foo(fn) diff --git a/test_all.sh b/test_all.sh index bd901b8..0f12064 100755 --- a/test_all.sh +++ b/test_all.sh @@ -43,6 +43,7 @@ function test_all { test_case "$BETEXC_PYTHON" "test/test_truncating_disabled.py" test_case "$BETEXC_PYTHON" "test/test_indentation_error.py" test_case "$BETEXC_PYTHON" "test/test_syntax_error.py" + test_case "$BETEXC_PYTHON" "test/test_file_without_colors.py" if [[ "$BETEXC_PYTHON" == "python3" ]]; then test_case "$BETEXC_PYTHON" "test/test_chaining.py"