Skip to content

Commit f34941b

Browse files
author
Emanuele Palazzetti
committed
[core] Config global object uses deepcopy once
1 parent a7c388b commit f34941b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ddtrace/configuration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from copy import deepcopy
2+
3+
14
class ConfigException(Exception):
25
"""Configuration exception when an integration that is not available
36
is called in the `Config` object.
@@ -33,4 +36,4 @@ def _add(self, integration, settings):
3336
since it contains integration defaults.
3437
"""
3538

36-
self._config[integration] = settings.copy()
39+
self._config[integration] = deepcopy(settings)

tests/test_configuration.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ def test_registration(self):
2222
def test_settings_copy(self):
2323
# ensure that once an integration is registered, a copy
2424
# of the settings is stored to avoid side-effects
25+
experimental = {
26+
'request_enqueuing': True,
27+
}
2528
settings = {
2629
'distributed_tracing': True,
30+
'experimental': experimental,
2731
}
2832
self.config._add('requests', settings)
2933

3034
settings['distributed_tracing'] = False
35+
experimental['request_enqueuing'] = False
3136
ok_(self.config.requests['distributed_tracing'] is True)
37+
ok_(self.config.requests['experimental']['request_enqueuing'] is True)
3238

3339
def test_missing_integration(self):
3440
# ensure a meaningful exception is raised when an integration
@@ -38,7 +44,6 @@ def test_missing_integration(self):
3844
self.config.new_integration['some_key']
3945

4046
ok_(isinstance(e.exception, ConfigException))
41-
eq_(e.exception.message, 'Integration "new_integration" is not registered in this configuration')
4247

4348
def test_global_configuration(self):
4449
# ensure a global configuration is available in the `ddtrace` module

0 commit comments

Comments
 (0)