Skip to content

Commit dcfa5c4

Browse files
committed
A helper for config stuff
1 parent b11d16e commit dcfa5c4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/plugin_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,21 @@ def run_django_coverage(
8686
tem = get_template(name or self.template_file)
8787
ctx = Context(context or {})
8888
self.cov = coverage.Coverage(**options)
89-
plugins = self.cov.config.get_option("run:plugins")
90-
plugins.append("django_coverage_plugin")
91-
self.cov.config.set_option("run:plugins", plugins)
89+
self.append_config("run:plugins", "django_coverage_plugin")
9290
if 0:
93-
self.cov.config["run:debug"].append("trace")
91+
self.append_config("run:debug", "trace")
9492
self.cov.start()
9593
text = tem.render(ctx)
9694
self.cov.stop()
9795
self.cov.save()
9896
return text
9997

98+
def append_config(self, option, value):
99+
"""Append to a configuration option."""
100+
val = self.cov.config.get_option(option)
101+
val.append(value)
102+
self.cov.config.set_option(option, val)
103+
100104
def get_line_data(self, name=None):
101105
"""Get the executed-line data for a template.
102106

0 commit comments

Comments
 (0)