Skip to content

#3829 -- Add the ability to show test progress as number of tests completed instead of a percent.#3880

Merged
nicoddemus merged 9 commits into
pytest-dev:featuresfrom
jeffreyrack:3829-progress_display_mode
Aug 28, 2018
Merged

#3829 -- Add the ability to show test progress as number of tests completed instead of a percent.#3880
nicoddemus merged 9 commits into
pytest-dev:featuresfrom
jeffreyrack:3829-progress_display_mode

Conversation

@jeffreyrack

Copy link
Copy Markdown
Member

Implements #3829 by adding a config value that can be used to show the test progress as the number of completed tests instead of a percentage complete.

Wasn't sure where to add the documentation for this, but am willing to go and add it if somebody can suggest a good spot to mention the new config value in.

@coveralls

coveralls commented Aug 26, 2018

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.09%) to 92.642% when pulling 4b94760 on jeffreyrack:3829-progress_display_mode into 044d2b8 on pytest-dev:features.

@nicoddemus

Copy link
Copy Markdown
Member

Thanks for tackling this @jeffreyrack!

The counter text is going over the edge when the number of tests make the progress doesn't fit on a single line, at least for me on Windows:

======================== test session starts ========================
...
collected 2131 items

testing\acceptance_test.py ...............s...................[   35 / 2131 ]
............s.x................                       [   66 / 2131 ]
testing\deprecated_test.py ......F.s.....             [   80 / 2131 ]
testing\test_argcomplete.py ss                        [   82 / 2131 ]

How does it look on your system?

Also with -v the counter text is right next to the status:

testing/acceptance_test.py::TestGeneralUsage::test_config_error PASSED[    1 / 2131 ]

I think there should be a space between them:

testing/acceptance_test.py::TestGeneralUsage::test_config_error PASSED [    1 / 2131 ]

Finally, a little of bike shedding: I think we don't need the space between brackets and the numbers: [ 18/2131] instead of [ 18 / 2131 ]. It occupies less space and is more pleasant to the eyes (the latter my opinion of course).

@nicoddemus

Copy link
Copy Markdown
Member

About where to put the docs: we should put the new option in reference.rst, at least.

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also take a look at _PROGRESS_LENGTH and where it is used to fix the "past the edge" problem I mentioned. 👍

Comment thread src/_pytest/terminal.py Outdated
Comment thread changelog/3829.feature.rst Outdated
Comment thread src/_pytest/terminal.py Outdated
Comment thread src/_pytest/terminal.py Outdated
if self.config.getoption("setupshow"):
return False
return self.config.getini("console_output_style") == "progress"
return (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest to use simply:

return self.config.getini("console_output_style") in ("progress", "count")

Comment thread src/_pytest/terminal.py Outdated
if self.config.getini("console_output_style") == "count":
num_tests = self._session.testscollected
_PROGRESS_LENGTH = len(
" [ {} / {} ]".format(str(num_tests), str(num_tests))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about using " [{}/{}]" here?

Comment thread src/_pytest/terminal.py Outdated
def pytest_runtest_logfinish(self, nodeid):
if self.config.getini("console_output_style") == "count":
num_tests = self._session.testscollected
_PROGRESS_LENGTH = len(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that this is no longer a constant, this should be lower case to conform to PEP-8: progress_length

Comment thread src/_pytest/terminal.py
counter_format = "{{:{}d}}".format(len(str(collected)))
format_string = " [ {} / {{}} ]".format(counter_format)
return format_string.format(len(progress), collected)
return " [ {} / {} ]".format(collected, collected)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto here for " [{}/{}]"

@codecov

codecov Bot commented Aug 27, 2018

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (features@044d2b8). Click here to learn what that means.
The diff coverage is 94.11%.

Impacted file tree graph

@@             Coverage Diff             @@
##             features    #3880   +/-   ##
===========================================
  Coverage            ?   92.64%           
===========================================
  Files               ?       51           
  Lines               ?     9975           
  Branches            ?        0           
===========================================
  Hits                ?     9241           
  Misses              ?      734           
  Partials            ?        0
Impacted Files Coverage Δ
src/_pytest/terminal.py 94.35% <94.11%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 044d2b8...4b94760. Read the comment docs.

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work @jeffreyrack, thanks!

@nicoddemus nicoddemus merged commit a605ad4 into pytest-dev:features Aug 28, 2018
@jeffreyrack jeffreyrack deleted the 3829-progress_display_mode branch April 4, 2019 04:35
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.

3 participants