Skip to content

Commit

Permalink
chore: update injector tests
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma committed Jul 17, 2024
1 parent 628c426 commit c73bb74
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions tests/injector/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PrototypeValueWrapper(cdf.injector.PrototypeMixin, ValueWrapper):


class BasicConfig(cdf.injector.Config):
x = cdf.injector.Object(1)
x = cdf.injector.Instance(1)
y: int = cdf.injector.Prototype(lambda x, offset: x + offset, x, offset=1)

foo = SingletonValueWrapper(value=x)
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_perturb_basic(more_type_safe: bool) -> None:

config0.x = 2
spec_x = config0._get_spec("x")
assert isinstance(spec_x, cdf.injector.specs._Object)
assert isinstance(spec_x, cdf.injector.specs._Instance)
assert spec_x.obj == 2

# Note that there are no class-level interactions, so if we
Expand Down Expand Up @@ -114,15 +114,15 @@ class ParentConfig1(cdf.injector.Config):
basic_config = BasicConfig()

baz1 = SingletonValueWrapper(basic_config.x)
some_str1 = cdf.injector.Object("abc")
some_str1 = cdf.injector.Instance("abc")


class GrandParentConfig(cdf.injector.Config):
parent_config0 = ParentConfig0()
parent_config1 = ParentConfig1()

foobar = SingletonValueWrapper(parent_config0.basic_config.x)
some_str0 = cdf.injector.Object("hi")
some_str0 = cdf.injector.Instance("hi")


class ErrorGrandParentConfig(cdf.injector.Config):
Expand Down Expand Up @@ -225,9 +225,9 @@ def test_input_config(more_type_safe: bool) -> None:


class CollectionConfig(cdf.injector.Config):
x = cdf.injector.Object(1)
y = cdf.injector.Object(2)
z = cdf.injector.Object(3)
x = cdf.injector.Instance(1)
y = cdf.injector.Instance(2)
z = cdf.injector.Instance(3)

foo_tuple: tuple[int] = cdf.injector.SingletonTuple(x, y)
foo_list: list[int] = cdf.injector.SingletonList(x, y)
Expand Down Expand Up @@ -265,8 +265,8 @@ class ForwardConfig(cdf.injector.Config):


class PartialKwargsConfig(cdf.injector.Config):
x = cdf.injector.Object(1)
y = cdf.injector.Object(2)
x = cdf.injector.Instance(1)
y = cdf.injector.Instance(2)

partial_kwargs = cdf.injector.SingletonDict(x=x, y=y)

Expand All @@ -280,7 +280,7 @@ class PartialKwargsConfig(cdf.injector.Config):
class PartialKwargsOtherConfig(cdf.injector.Config):
partial_kwargs_config = PartialKwargsConfig()

z = cdf.injector.Object(3)
z = cdf.injector.Instance(3)
values = cdf.injector.Singleton( # type: ignore[call-arg]
ValuesWrapper,
z=z,
Expand Down
2 changes: 1 addition & 1 deletion tests/injector/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_perturb_nested(more_type_safe: bool) -> None:

class MoreComplexPerturbConfig0(cdf.injector.Config):
x: int = cdf.injector.GlobalInput(type_=int)
y: int = cdf.injector.Object(2)
y: int = cdf.injector.Instance(2)

foo = cdf.injector.Singleton(test_config.ValueWrapper, 100)

Expand Down
2 changes: 1 addition & 1 deletion tests/injector/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class EngineConfig(cdf.injector.Config):
class CarConfig(cdf.injector.Config):
engine_config = EngineConfig()

seat_cls = cdf.injector.Object(Seat)
seat_cls = cdf.injector.Instance(Seat)
seats = cdf.injector.Prototype(
lambda cls, n: [cls() for _ in range(n)], seat_cls, 2
)
Expand Down
6 changes: 3 additions & 3 deletions tests/injector/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def add_ints(x: int, y: int) -> int:


def test_typing() -> None:
spec0: int = cdf.injector.Object(1)
spec1: int = cdf.injector.Object(2)
spec2: str = cdf.injector.Object("abc")
spec0: int = cdf.injector.Instance(1)
spec1: int = cdf.injector.Instance(2)
spec2: str = cdf.injector.Instance("abc")

_3: int = cdf.injector.GlobalInput(type_=int) # noqa: F841
_4: str = cdf.injector.LocalInput(type_=str) # noqa: F841
Expand Down

0 comments on commit c73bb74

Please sign in to comment.