Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have at least one separator in sep() #204

Merged
merged 1 commit into from
Nov 23, 2018
Merged

Have at least one separator in sep() #204

merged 1 commit into from
Nov 23, 2018

Conversation

asottile
Copy link
Member

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

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 =
```
@RonnyPfannschmidt
Copy link
Member

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

@RonnyPfannschmidt
Copy link
Member

question - how does this affect normal terminal output?

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

@RonnyPfannschmidt
Copy link
Member

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
Copy link
Member Author

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:

  • 77 characters ends up with a single separator on the right (???)
  • 79 characters wraps, the wrapping character is a space 😆

after

@asottile
Copy link
Member Author

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
Copy link
Member

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

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it also solves a pytest issue that's hidden somewhere about no longer being able to distinguish certain things

@asottile
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants