Skip to content

Commit

Permalink
Add unit test for exception inside @Property (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Oct 21, 2019
1 parent d41d922 commit 12d5171
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/exceptions/output/others/exception_in_property.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Traceback (most recent call last):

File "tests/exceptions/source/others/exception_in_property.py", line 22, in <module>
value = a.value
│ └ <property object at 0xDEADBEEF>
└ <__main__.A object at 0xDEADBEEF>

> File "tests/exceptions/source/others/exception_in_property.py", line 13, in value
1 / 0

ZeroDivisionError: division by zero
22 changes: 22 additions & 0 deletions tests/exceptions/source/others/exception_in_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
from loguru import logger


logger.remove()
logger.add(sys.stderr, format="", diagnose=True, backtrace=True, colorize=False)


class A:
@property
def value(self):
try:
1 / 0
except:
logger.opt(exception=True).debug("test")
return None
else:
return "Never"


a = A()
value = a.value
1 change: 1 addition & 0 deletions tests/test_catch_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def test_exception_ownership(filename):
"exception_formatting_coroutine",
"exception_formatting_function",
"exception_formatting_generator",
"exception_in_property",
"handler_formatting_with_context_manager",
"handler_formatting_with_decorator",
"level_name",
Expand Down

0 comments on commit 12d5171

Please sign in to comment.