Hi Harry,

To the best of my knowledge you stumbled into a hard and dark corner of
pytest.  IIRC previous attempts at improving this have not gone too
well.  But like this always goes, it sounds like you've set yourself up
to be the expert now and are in a great position to clean this up and
make it work nicely for people.  ;)

Cheers,
Floris

On Tue 07 Apr 2020 at 19:26 +0100, Harry Percival wrote:

> cf discussion here https://github.com/pytest-dev/pytest/issues/162
>
> I'm working on pytest-icdiff, trying to get it to print out well optimised
> messages for different terminal sizes, and it's hard.
>
> when i'm running tests using runpytest, and I _think_ in real life too,
> config.get_terminal_writer().fullwidth *inside the hook* is returning
> incorrect values: resizing the terminal i'm using to run the tests has no
> effect on the value i get from it.  and when I use that value irl, real
> test output does not adjust correctly to the terminal size
>
> but calling py.io.TerminalWriter().fullwidth _outside_ the hook, eg at
> module level, _does_ give me readings that look right.  but testing  that
> is hard.
>
> intriguingly, if I do testdir.monkeypatch.setenv('COLUMNS', '50'), then the
> fullwdith *inside* the hook varies.  but that's no use to me, since IRL
> that value doesn't work.
>
> so my question is: a) does anyone know of any good examples of assertrepr
> plugins that adjust dynamically to terminal width, and b) what's a good way
> of writing tests for that?
>
> here's the repo fwiw
> https://github.com/hjwp/pytest-icdiff/blob/master/tests/test_pytest_icdiff.py
> _______________________________________________
> pytest-dev mailing list
> pytest-dev@python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to