mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-16 19:40:59 +03:00
Fix wiring module loader uninstallation issue
This commit is contained in:
parent
a7de2dc632
commit
702df9676c
|
@ -12,6 +12,7 @@ Development version
|
|||
- Implement providers' lazy initialization.
|
||||
- Improve providers' copying.
|
||||
- Improve typing in wiring module.
|
||||
- Fix wiring module loader uninstallation issue.
|
||||
|
||||
4.30.0
|
||||
------
|
||||
|
|
|
@ -860,7 +860,7 @@ class AutoLoader:
|
|||
|
||||
@property
|
||||
def installed(self):
|
||||
return self._path_hook is not None
|
||||
return self._path_hook in sys.path_hooks
|
||||
|
||||
def install(self):
|
||||
if self.installed:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import contextlib
|
||||
from decimal import Decimal
|
||||
import importlib
|
||||
import unittest
|
||||
|
||||
from dependency_injector.wiring import (
|
||||
|
@ -6,6 +8,8 @@ from dependency_injector.wiring import (
|
|||
Provide,
|
||||
Provider,
|
||||
Closing,
|
||||
register_loader_containers,
|
||||
unregister_loader_containers,
|
||||
)
|
||||
from dependency_injector import containers, providers, errors
|
||||
|
||||
|
@ -409,27 +413,27 @@ class WiringAsyncInjectionsTest(AsyncTestCase):
|
|||
self.assertEqual(asyncinjections.resource2.shutdown_counter, 2)
|
||||
|
||||
|
||||
# class AutoLoaderTest(unittest.TestCase):
|
||||
#
|
||||
# container: Container
|
||||
#
|
||||
# def setUp(self) -> None:
|
||||
# self.container = Container(config={'a': {'b': {'c': 10}}})
|
||||
# importlib.reload(module)
|
||||
#
|
||||
# def tearDown(self) -> None:
|
||||
# with contextlib.suppress(ValueError):
|
||||
# unregister_loader_containers(self.container)
|
||||
#
|
||||
# self.container.unwire()
|
||||
#
|
||||
# @classmethod
|
||||
# def tearDownClass(cls) -> None:
|
||||
# importlib.reload(module)
|
||||
#
|
||||
# def test_register_container(self):
|
||||
# register_loader_containers(self.container)
|
||||
# importlib.reload(module)
|
||||
#
|
||||
# service = module.test_function()
|
||||
# self.assertIsInstance(service, Service)
|
||||
class AutoLoaderTest(unittest.TestCase):
|
||||
|
||||
container: Container
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.container = Container(config={'a': {'b': {'c': 10}}})
|
||||
importlib.reload(module)
|
||||
|
||||
def tearDown(self) -> None:
|
||||
with contextlib.suppress(ValueError):
|
||||
unregister_loader_containers(self.container)
|
||||
|
||||
self.container.unwire()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls) -> None:
|
||||
importlib.reload(module)
|
||||
|
||||
def test_register_container(self):
|
||||
register_loader_containers(self.container)
|
||||
importlib.reload(module)
|
||||
|
||||
service = module.test_function()
|
||||
self.assertIsInstance(service, Service)
|
||||
|
|
Loading…
Reference in New Issue
Block a user