Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution of unregistered constructor dependencies #185

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/src/*.egg-info/
__pycache__/
.eggs
.idea
28 changes: 28 additions & 0 deletions tests/test_dynamic_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from punq import Container, Scope


class ConstructorDependency1:
pass


class ConstructorDependency2:
pass


class TraditionalClass:
def __init__(
self,
dependency1: ConstructorDependency1,
dependency2: ConstructorDependency2,
):
self.dependency1 = dependency1
self.dependency2 = dependency2


def test_can_resolve_dependencies_in_constructor_without_registration():
container = Container()
# container.register(ConstructorDependency1)
# container.register(ConstructorDependency2)
# ToDo: ^ The test will pass if we uncomment those or implement the feature.
container.register(TraditionalClass)
container.resolve(TraditionalClass)