From a9f27e32473ef6eb020103d168804b6044fd19a7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 6 Jun 2016 23:19:14 +0200 Subject: [PATCH] bdd: Turn off colors with --color=no --- tests/end2end/fixtures/quteprocess.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 38bd9aa7a..9182981e7 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -136,6 +136,7 @@ class QuteProc(testprocess.Process): _profile: If True, do profiling of the subprocesses. _instance_id: An unique ID for this QuteProc instance _run_counter: A counter to get an unique ID for each run. + _config: The pytest config object Signals: got_error: Emitted when there was an error log line. @@ -146,7 +147,8 @@ class QuteProc(testprocess.Process): KEYS = ['timestamp', 'loglevel', 'category', 'module', 'function', 'line', 'message'] - def __init__(self, httpbin, delay, *, profile=False, parent=None): + def __init__(self, httpbin, delay, *, profile=False, config=None, + parent=None): super().__init__(parent) self._profile = profile self._delay = delay @@ -157,6 +159,7 @@ class QuteProc(testprocess.Process): self._load_ready = False self._instance_id = next(instance_counter) self._run_counter = itertools.count() + self._config = config def _is_ready(self, what): """Called by _parse_line if loading/focusing is done. @@ -183,8 +186,11 @@ class QuteProc(testprocess.Process): else: raise - colored_line = log_line.formatted_str() - self._log(colored_line) + if self._config.getoption('--color') != 'no': + line_to_log = log_line.formatted_str() + else: + line_to_log = log_line.formatted_str(colorized=False) + self._log(line_to_log) start_okay_message_load = ( "load status for