mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 04:19:03 +00:00
Handle exception chain on addon boot (#2063)
* Handle exception chain on addon boot * fix import * Add tests
This commit is contained in:
36
tests/utils/test_exception_helper.py
Normal file
36
tests/utils/test_exception_helper.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""Test exception helpers."""
|
||||
|
||||
from supervisor.utils import check_exception_chain
|
||||
|
||||
|
||||
def test_simple_chain_exception():
|
||||
"""Test simple chain of excepiton."""
|
||||
|
||||
try:
|
||||
raise ValueError()
|
||||
except ValueError as err:
|
||||
assert check_exception_chain(err, ValueError)
|
||||
|
||||
|
||||
def test_simple_nested_chain_exception():
|
||||
"""Test simple nested chain of excepiton."""
|
||||
|
||||
try:
|
||||
try:
|
||||
raise ValueError()
|
||||
except ValueError as err:
|
||||
raise KeyError() from err
|
||||
except KeyError as err:
|
||||
assert check_exception_chain(err, ValueError)
|
||||
|
||||
|
||||
def test_list_nested_chain_exception():
|
||||
"""Test list nested chain of excepiton."""
|
||||
|
||||
try:
|
||||
try:
|
||||
raise ValueError()
|
||||
except ValueError as err:
|
||||
raise KeyError() from err
|
||||
except KeyError as err:
|
||||
assert check_exception_chain(err, (ValueError, OSError))
|
||||
Reference in New Issue
Block a user