Fix leak from tempest.conf in fake_config fixture
The config fixture used in Tempest unit tests
(tests.fake_config.ConfigFixture) does not reset the
cfg.CONF/config.CONF values when the test class is initialized.
If config.CONF already exists (e.g. with values from tempest.conf file
that have been retrieved during test discovery/load), then incorrect
config settings might be used during a unit test.
There is a statement to (re)initialize cfg.CONF in the init of
tests.fake_config.FakePrivate (this is a stub for
config.TempestConfigPrivate). However if config.CONF already has
attribute _config (of type TempestConfigPrivate), then
TempestConfigPrivate is not called during the test (due to
logic in __getattr__ method in config.TempestConfigProxy class). So if
config.CONF was created before start of the unit test, stub FakePrivate
is not initialized and as a result cfg.CONF is not reset.
This patch moves the (re)initialization of cfg.CONF from FakePrivate to
ConfigFixture class to ensure that cfg.CONF/config.CONF reset is also
executed if config.CONF already exists before start of the unit test.
Partial-Bug: #1508815
Change-Id: I9525628ffd263dd2ed3ad2411f24548dfd50f747
1 file changed