Skip to content

Commit

Permalink
Make integration tests more meaningful
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 1, 2023
1 parent f799293 commit e0e2c5b
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,28 @@ def test_passes_container_bc_name(self, registry, container):
If the factory takes an argument called `svcs_container`, it is passed
on instantiation.
"""
called = False

def factory(svcs_container):
assert container is svcs_container
nonlocal called
called = True
return str(svcs_container.get(int))

registry.register_factory(Service, factory)

container.get(Service)
registry.register_value(int, 42)
registry.register_factory(str, factory)

assert called
assert "42" == container.get(str)

def test_passes_container_bc_annotation(self, registry, container):
"""
If the factory takes an argument annotated with svcs.Container, it is
passed on instantiation.
"""
called = False

def factory(foo: svcs.Container):
assert container is foo
nonlocal called
called = True
return str(foo.get(int))

registry.register_factory(Service, factory)

container.get(Service)
registry.register_value(int, 42)
registry.register_factory(str, factory)

assert called
assert "42" == container.get(str)


class TestContainer:
Expand Down

0 comments on commit e0e2c5b

Please sign in to comment.