Skip to content

Commit 65fa4ba

Browse files
author
Emanuele Palazzetti
committed
[core] regression test to avoid copying the configuration at init time
1 parent fa00f0d commit 65fa4ba

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_instance_config.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_service_attribute_priority(self):
6868
eq_(cfg['service_name'], 'service')
6969

7070
def test_configuration_copy(self):
71-
# ensure when a Pin is created, it copies the given configuration
71+
# ensure when a Pin is used, the given configuration is copied
7272
global_config = {
7373
'service_name': 'service',
7474
}
@@ -77,3 +77,18 @@ def test_configuration_copy(self):
7777
cfg = config.get_from(instance)
7878
cfg['service_name'] = 'metrics'
7979
eq_(global_config['service_name'], 'service')
80+
81+
def test_configuration_copy_upside_down(self):
82+
# ensure when a Pin is created, it does not copy the given configuration
83+
# until it's used for at least once
84+
global_config = {
85+
'service_name': 'service',
86+
}
87+
Pin(service='service', _config=global_config).onto(self.Klass)
88+
# override the global config: users do that before using the integration
89+
global_config['service_name'] = 'metrics'
90+
# use the Pin via `get_from`
91+
instance = self.Klass()
92+
cfg = config.get_from(instance)
93+
# it should have users updated value
94+
eq_(cfg['service_name'], 'metrics')

0 commit comments

Comments
 (0)