pytest: Terminal width inference issues causing doctest failures
Greetings. Thanks for your work on an excellent library!
I am writing some doctests whose output seems to be sensitive to the width of the terminal—dumps of Pandas dataframes that sometimes exceed 80 chars in width. When I run the commands on the Python interpreter interactively, I can reproduce the Pandas behavior: when the window is wide, the full table is printed; when the window is narrow, columns in the middle are truncated.
I can confirm that doctest handles things correctly as well. When I execute python -m doctest myfile.py
with the window at 80 chars width, the output is truncated and the test fails. When I execute the same command at 120 chars width, the output is not truncated and the doctests pass.
However, when running py.test --doctest-module myfile.py
the tests fail regardless of window width. I can restart my window manager (tmux), I can restart the window manager, resize the window itself, or even close the window and start over from scratch, but no combination of these operations seems to convince py.test that my terminal is wider than 80 chars.
This isn’t a problem on my personal machine (OS X High Sierra) but it is on a work CentOS 6 system running py.test 3.6.2.
Thanks for submitting an issue!
Here’s a quick checklist in what to include:
- Include a detailed description of the bug or suggestion
- <strike>[ ]
pip list
of the virtual environment you are using</strike> - pytest and operating system versions
- Minimal example if possible
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (12 by maintainers)
Oops, since I can’t update your example it’s:
Actually, I had to set both. Only increasing the width truncated the number of columns, and only increasing the number of columns just wrapped the output at 80 chars. Doing both did the trick!
Updating the example now.
Thanks!!!
this wouldn’t go in
pytest
itself, but in your test suite – probably as anautouse=True, scope='session'
fixture
in yourconftest.py