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.
|
||||
:rtype: :py:class:`OverridingContext`
|
||||
"""
|
||||
if provider is None:
|
||||
provider = {}
|
||||
context = super().override(provider)
|
||||
self.reset_cache()
|
||||
return context
|
||||
|
|
|
@ -185,6 +185,13 @@ class ConfigTests(unittest.TestCase):
|
|||
with self.assertRaises(AttributeError):
|
||||
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):
|
||||
provider = providers.Configuration('config')
|
||||
provider_copy = providers.deepcopy(provider)
|
||||
|
|
Loading…
Reference in New Issue