-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_load_profile.py
More file actions
36 lines (24 loc) · 852 Bytes
/
test_load_profile.py
File metadata and controls
36 lines (24 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from injection import find_instance, injectable, mod
from injection.loaders import load_profile
class TestLoadProfile:
def test_load_profile_with_success(self):
profile_name = "test"
@injectable
class A: ...
@mod(profile_name).injectable(on=A)
class B(A): ...
assert type(find_instance(A)) is A
load_profile(profile_name)
assert type(find_instance(A)) is B
# Cleaning
mod().init_modules()
def test_load_profile_with_context_manager(self):
profile_name = "test"
@injectable
class A: ...
@mod(profile_name).injectable(on=A)
class B(A): ...
assert type(find_instance(A)) is A
with load_profile(profile_name):
assert type(find_instance(A)) is B
assert type(find_instance(A)) is A