mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-04 20:33:13 +03:00
Migrate misc wiring tests
This commit is contained in:
parent
14449c4538
commit
835406da65
|
@ -0,0 +1,20 @@
|
||||||
|
"""Tests for wiring to module as package."""
|
||||||
|
|
||||||
|
from pytest import fixture
|
||||||
|
|
||||||
|
from wiringsamples import module
|
||||||
|
from wiringsamples.service import Service
|
||||||
|
from wiringsamples.container import Container
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def container():
|
||||||
|
container = Container()
|
||||||
|
yield container
|
||||||
|
container.unwire()
|
||||||
|
|
||||||
|
|
||||||
|
def test_module_as_package_wiring(container: Container):
|
||||||
|
# See: https://github.com/ets-labs/python-dependency-injector/issues/481
|
||||||
|
container.wire(packages=[module])
|
||||||
|
assert isinstance(module.service, Service)
|
|
@ -4,7 +4,6 @@ from dependency_injector.wiring import (
|
||||||
Provide,
|
Provide,
|
||||||
Closing,
|
Closing,
|
||||||
)
|
)
|
||||||
from dependency_injector import containers, errors
|
|
||||||
|
|
||||||
# Runtime import to avoid syntax errors in samples on Python < 3.5
|
# Runtime import to avoid syntax errors in samples on Python < 3.5
|
||||||
import os
|
import os
|
||||||
|
@ -29,18 +28,6 @@ from wiringsamples.service import Service
|
||||||
from wiringsamples.container import Container
|
from wiringsamples.container import Container
|
||||||
|
|
||||||
|
|
||||||
class ModuleAsPackageTest(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.container = Container(config={"a": {"b": {"c": 10}}})
|
|
||||||
self.addCleanup(self.container.unwire)
|
|
||||||
|
|
||||||
def test_module_as_package_wiring(self):
|
|
||||||
# See: https://github.com/ets-labs/python-dependency-injector/issues/481
|
|
||||||
self.container.wire(packages=[module])
|
|
||||||
self.assertIsInstance(module.service, Service)
|
|
||||||
|
|
||||||
|
|
||||||
class WiringAndQueue(unittest.TestCase):
|
class WiringAndQueue(unittest.TestCase):
|
||||||
|
|
||||||
def test_wire_queue(self) -> None:
|
def test_wire_queue(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user