-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Raise exception instead of hiding it in finally (#845)
- Loading branch information
1 parent
d82d9fb
commit f9db578
Showing
2 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/unit/providers/singleton/test_thread_local_singleton_py3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from dependency_injector.containers import Container | ||
from dependency_injector.providers import ThreadLocalSingleton | ||
|
||
|
||
class FailingClass: | ||
def __init__(self): | ||
raise ValueError("FAILING CLASS") | ||
|
||
|
||
class TestContainer(Container): | ||
failing_class = ThreadLocalSingleton(FailingClass) | ||
|
||
|
||
def test_on_failure_value_error_is_raised(): | ||
container = TestContainer() | ||
|
||
with pytest.raises(ValueError, match="FAILING CLASS"): | ||
container.failing_class() |