Skip to content

Add support for color output in invoke #47

Closed
@aiven-sal

Description

@aiven-sal

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"
        )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions