Skip to content

Commit

Permalink
tests: always clone configuration to support decorator config overrides
Browse files Browse the repository at this point in the history
When decorators are used to alter the test case's configuration, this
is applied to a base configuration prepared for the entire test class.
This could then result in some unit tests changing other unit test's
configuration, depending on how the unit test order is run. To prevent
unexpected configuration changes, always clone the base configuration
when running a prepare/build invoke.

Signed-off-by: James Knight <[email protected]>
  • Loading branch information
jdknight committed Nov 18, 2023
1 parent 58bc3cb commit 5d1604c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/lib/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def build(self, *args, **kwargs):

new_kwargs = dict(kwargs)
new_kwargs.setdefault('builder', self.builder)
new_kwargs.setdefault('config', self.config)
new_kwargs.setdefault('config', self.config.clone())
if self.target_editor:
new_kwargs['config']['confluence_editor'] = self.target_editor

Expand All @@ -78,7 +78,7 @@ def prepare(self, *args, **kwargs):

new_kwargs = dict(kwargs)
new_kwargs.setdefault('builder', self.builder)
new_kwargs.setdefault('config', self.config)
new_kwargs.setdefault('config', self.config.clone())
if self.target_editor:
new_kwargs['config']['confluence_editor'] = self.target_editor

Expand Down

0 comments on commit 5d1604c

Please sign in to comment.