pytest-dev / py

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

Have at least one separator in sep() #204

Closed asottile closed 5 years ago

asottile commented 5 years ago

Before:

 1 failed, 1 passed, 1 skipped, 1 deselected, 1 xfailed, 1 xpassed, 1 error in 0.04 seconds

After:

= 1 failed, 1 passed, 1 skipped, 1 deselected, 1 xfailed, 1 xpassed, 1 error in 0.04 seconds =

This is slightly selfish -- I'm doing this to make the output in this case possible to colorize for pygments-pytest

RonnyPfannschmidt commented 5 years ago

i cant wait to kill the pylib dependency of terminal-writer ^^

RonnyPfannschmidt commented 5 years ago

question - how does this affect normal terminal output?

if this triggers line-wraps of separator lines for single separators, then its absolutely unacceptable

RonnyPfannschmidt commented 5 years ago

as for a solution - if that is the case - we could opt in or out based on whether its a tty - but it would trigger inconsistent line lengths

asottile commented 5 years ago

This change can cause more wrapping, but I think the consistency in output is worth it.

Here's a small demo:

from py.io import TerminalWriter

tw = TerminalWriter()

for i in range(70, 82):
    msg = f'{i} chars: '
    msg += 'X' * (i - len(msg))
    tw.sep('=', msg)
    print()

before

Some notably bad actors:

after

asottile commented 5 years ago

basically, the only time this is going to make a difference is when the centered string is N - 3 and N - 2 characters in length -- otherwise it was already going to wrap

RonnyPfannschmidt commented 5 years ago

@asottile this is about as bad as rubbing my ocd with napalm

asottile commented 5 years ago

oh right, I don't have merge or release privs here 🙃