Closed
Description
invoke tasks should have an optional CLI argument that default to False (e.g. --colors) that forces pytest (and maybe other commands) to output colors even if it doesn't detect a tty.
e.g.
@task
def standalone_tests(c, uvloop=False, protocol=2, colors=False):
"""Run tests against a standalone valkey instance"""
if uvloop:
run(
f"pytest --color={'yes' if colors else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
)
else:
run(
f"pytest --color={'yes' if colors else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml"
)
or we can take the chance to simplify the code and do:
@task
def standalone_tests(c, uvloop=False, protocol=2, colors=False):
"""Run tests against a standalone valkey instance"""
run(
f"pytest --color={'yes' if colors else 'no'} --protocol={protocol} "
"--cov=./ --cov-report=xml:coverage_valkey.xml -W always "
f"-m 'not onlycluster' {'--uvloop' if uvloop else ''} "
"--junit-xml=standalone-results.xml"
)