-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Console progress output #2858
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
Console progress output #2858
Conversation
beb2e11
to
562ea0f
Compare
_pytest/terminal.py
Outdated
@@ -155,13 +160,37 @@ def _tw(self): | |||
stacklevel=2) | |||
return self.writer | |||
|
|||
@staticmethod | |||
def _new_tw_write(msg, **kw): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course this is hackish. 😉
I believe the correct thing would be to add this functionality to py.io.TerminalWriter
instead, what do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before i tried to kill TerminalWriter altogether - it deserves a general removal as its quite bad as an api and people regularly try to obtain it in a hackish was inside of pytest
_pytest/terminal.py
Outdated
@@ -320,7 +375,7 @@ def report_collect(self, final=False): | |||
if skipped: | |||
line += " / %d skipped" % skipped | |||
if self.isatty: | |||
self.rewrite(line, bold=True, erase=True) | |||
self.writer.reline(line, bold=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids the flickering while collecting, not really related.
|
||
self.stats = {} | ||
self.startdir = py.path.local() | ||
if file is None: | ||
file = sys.stdout | ||
self._writer = _pytest.config.create_terminal_writer(config, file) | ||
self._screen_width = self.writer.fullwidth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to cache this otherwise I noticed a good 20% performance penalty. We probably need to fix this in py
somehow, which we have tried to do in the past.
1e95642
to
d01e871
Compare
setup.py
Outdated
@@ -45,7 +45,7 @@ def has_environment_marker_support(): | |||
def main(): | |||
extras_require = {} | |||
install_requires = [ | |||
'py>=1.4.33', | |||
'py>=1.5.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase to avoid this bit creating issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, I'm still working on this.
4658781
to
456871c
Compare
I will also add an ini option ( |
Still needs to update the docs and CHANGELOG. I will get to it on Monday. |
5a2d55e
to
2455f86
Compare
Cleaned up commits and added what was missing, so this is now ready for review as far as I'm concerned. 😁 |
01391b9
to
f05333a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't really reviewed the logic clearly - I commented on what caught my eye at 7am 😉
_pytest/pytester.py
Outdated
"""Check lines exist in the output. | ||
|
||
The argument is a list of lines which have to occur in the | ||
output, in any order. Each line can contain glob whildcards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whildcards -> wildcards - but it looks like this actually takes a regex pattern, and not globs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
self.currentfspath = None | ||
self.reportchars = getreportopt(config) | ||
self.hasmarkup = self.writer.hasmarkup | ||
self.isatty = file.isatty() | ||
self._progress_items_reported = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have no way already to get how many tests have run so far?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of; usually this is not really tracked by pytest explicitly, each runtestprotocol
just triggers the appropriate hooks and each plugin does with that information what it needs.
testing/test_terminal.py
Outdated
def test_normal(self, many_tests_file, testdir): | ||
output = testdir.runpytest() | ||
output.stdout.re_match_lines([ | ||
r'test_bar.py \.\.\.\.\.\.\.\.\.\. \s+ \[ 50%\]', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to do \.{10}
here and in other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely 👍
@The-Compiler thanks for the review, I believe I have addressed all your comments so far. 👍 |
Note: this progress output inspired pytest-dev/py#196 |
@wimglenn definitely! Thanks a lot for that implementation no |
Still needs tests, docs and some cleanup, I'm opening this to gather some feedback.
This works in "normal" mode (including xdist), still needs work with
-v
.Please see comments below.