Consider --color option in more places which deal with TerminalWriters

This commit is contained in:
Bruno Oliveira
2015-07-18 16:39:55 -03:00
parent 23aaa8a62c
commit 2f7d0f8bd9
9 changed files with 37 additions and 10 deletions

View File

@@ -933,3 +933,16 @@ def setns(obj, dic):
#if obj != pytest:
# pytest.__all__.append(name)
setattr(pytest, name, value)
def create_terminal_writer(config, *args, **kwargs):
"""Create a TerminalWriter instance configured according to the options
in the config object. Every code which requires a TerminalWriter object
and has access to a config object should use this function.
"""
tw = py.io.TerminalWriter(*args, **kwargs)
if config.option.color == 'yes':
tw.hasmarkup = True
if config.option.color == 'no':
tw.hasmarkup = False
return tw