pytest-dev / py

Python development support library (note: maintenance only)
MIT License
67 stars 106 forks source link

[WIP/TEST] terminalwriter: use colorama also for non-tty (Travis) #224

Closed blueyed closed 5 years ago

blueyed commented 5 years ago

This is meant to have colors on CI / Travis (Windows) also.

Currently fails tests on AppVeyor/Windows, e.g.:

____________________ test_should_do_markup_PY_COLORS_eq_1 _____________________
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000000046C4E80>
    def test_should_do_markup_PY_COLORS_eq_1(monkeypatch):
        monkeypatch.setitem(os.environ, 'PY_COLORS', '1')
        tw = py.io.TerminalWriter(stringio=True)
        assert tw.hasmarkup
        tw.line("hello", bold=True)
        s = tw.stringio.getvalue()
>       assert len(s) > len("hello\n")
E       AssertionError: assert 6 > 6
E        +  where 6 = len('hello\n')
E        +  and   6 = len('hello\n')
testing\io_\test_terminalwriter.py:293: AssertionError

Likely it is using real Windows colors there already?

I do not really plan to work on this, feel free to adopt or close.

blueyed commented 5 years ago

Does not use colors on Travis/Windows still: https://travis-ci.com/pdbpp/pdbpp/jobs/225971063#L125.

Using --color=yes with pytest works, but only when using colorama (the default, but I am uninstalling it for tests in one env).