mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 11:04:01 +03:00
Fix a bug in the `Configuration
provider to correctly handle overriding by
None
`.
This commit is contained in:
parent
1cbd3a0215
commit
1c87a9973d
File diff suppressed because it is too large
Load Diff
|
@ -1507,6 +1507,8 @@ cdef class Configuration(Object):
|
||||||
:return: Overriding context.
|
:return: Overriding context.
|
||||||
:rtype: :py:class:`OverridingContext`
|
:rtype: :py:class:`OverridingContext`
|
||||||
"""
|
"""
|
||||||
|
if provider is None:
|
||||||
|
provider = {}
|
||||||
context = super().override(provider)
|
context = super().override(provider)
|
||||||
self.reset_cache()
|
self.reset_cache()
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -185,6 +185,13 @@ class ConfigTests(unittest.TestCase):
|
||||||
with self.assertRaises(AttributeError):
|
with self.assertRaises(AttributeError):
|
||||||
a.__name__
|
a.__name__
|
||||||
|
|
||||||
|
def test_missing_key(self):
|
||||||
|
# See: https://github.com/ets-labs/python-dependency-injector/issues/358
|
||||||
|
self.config.override(None)
|
||||||
|
value = self.config.key()
|
||||||
|
|
||||||
|
self.assertIsNone(value)
|
||||||
|
|
||||||
def test_deepcopy(self):
|
def test_deepcopy(self):
|
||||||
provider = providers.Configuration('config')
|
provider = providers.Configuration('config')
|
||||||
provider_copy = providers.deepcopy(provider)
|
provider_copy = providers.deepcopy(provider)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user