-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/mx 1596 simplify settings handling (#220)
# PR Context <!-- Additional info for the reviewer --> # Added <!-- New features and interfaces --> # Changes <!-- Changes in existing functionality --> # Deprecated <!-- Soon-to-be removed features --> # Removed <!-- Definitely removed features --> - BREAKING: ability to store different settings instances at the same time. Dependent repositories now must bundle all settings in a single class. # Fixed <!-- Fixed bugs --> # Security <!-- Fixed vulnerabilities -->
- Loading branch information
1 parent
ac95218
commit 62a502d
Showing
6 changed files
with
94 additions
and
77 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
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
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
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
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,31 @@ | ||
import pytest | ||
|
||
from mex.common.context import SingleSingletonStore | ||
|
||
|
||
class Parent: | ||
pass | ||
|
||
|
||
class Child(Parent): | ||
pass | ||
|
||
|
||
def test_single_singleton_store() -> None: | ||
store = SingleSingletonStore["Parent"]() | ||
parent = store.load(Parent) | ||
|
||
with pytest.raises(RuntimeError, match="is not a parent class of loaded class"): | ||
store.load(Child) | ||
|
||
assert parent is store.load(Parent) | ||
|
||
store.push(Child()) | ||
|
||
child = store.load(Child) | ||
|
||
assert child is store.load(Parent) | ||
|
||
store.reset() | ||
|
||
assert store._singleton is None |
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