Skip to content

Exclude durations that are 0.00 seconds long.#4086

Merged
nicoddemus merged 4 commits into
pytest-dev:masterfrom
jeffreyrack:4063-exclude-0-durations
Oct 14, 2018
Merged

Exclude durations that are 0.00 seconds long.#4086
nicoddemus merged 4 commits into
pytest-dev:masterfrom
jeffreyrack:4063-exclude-0-durations

Conversation

@jeffreyrack

Copy link
Copy Markdown
Member

Implements #4063 by excluding 0.00 second long durations from the --durations output unless -vv is used.

@coveralls

coveralls commented Oct 8, 2018

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 93.802% when pulling 3683d92 on jeffreyrack:4063-exclude-0-durations into 6660966 on pytest-dev:master.

@codecov

codecov Bot commented Oct 8, 2018

Copy link
Copy Markdown

Codecov Report

Merging #4086 into master will decrease coverage by 0.01%.
The diff coverage is 92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4086      +/-   ##
==========================================
- Coverage    94.5%   94.49%   -0.02%     
==========================================
  Files         109      109              
  Lines       23813    23820       +7     
  Branches     2349     2351       +2     
==========================================
+ Hits        22504    22508       +4     
- Misses       1001     1004       +3     
  Partials      308      308
Flag Coverage Δ
#doctesting ?
#linux 94.34% <92%> (-0.02%) ⬇️
#nobyte 0% <0%> (ø) ⬆️
#numpy 28.14% <4%> (+0.05%) ⬆️
#pexpect 0% <0%> (ø) ⬆️
#py27 92.66% <92%> (+0.03%) ⬆️
#py34 92.11% <92%> (+0.02%) ⬆️
#py35 92.13% <92%> (+0.02%) ⬆️
#py36 92.7% <92%> (+0.03%) ⬆️
#py37 92.33% <92%> (+0.02%) ⬆️
#trial 31.37% <4%> (+0.05%) ⬆️
#windows 93.79% <92%> (-0.06%) ⬇️
#xdist 18.57% <4%> (+0.01%) ⬆️
Impacted Files Coverage Δ
src/_pytest/runner.py 96.83% <100%> (+0.06%) ⬆️
testing/acceptance_test.py 97.81% <90%> (ø) ⬆️
src/_pytest/assertion/util.py 92.92% <0%> (-5.19%) ⬇️
src/_pytest/_argcomplete.py 73.52% <0%> (-0.76%) ⬇️
testing/test_pdb.py 52.7% <0%> (-0.44%) ⬇️
src/_pytest/fixtures.py 97.29% <0%> (ø) ⬆️
src/_pytest/mark/evaluate.py 96.66% <0%> (ø) ⬆️
src/_pytest/logging.py 95.65% <0%> (ø) ⬆️
src/_pytest/main.py 96.19% <0%> (ø) ⬆️
testing/code/test_excinfo.py 96.74% <0%> (+0.1%) ⬆️
... and 2 more

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 6660966...3683d92. Read the comment docs.

@RonnyPfannschmidt RonnyPfannschmidt 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.

at first glance this looks great, nice simple and opt-out-able

@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!

I made a few minor comments, please let me know what you think.

Also, I think we can mention this in the docs. I think just adding something like:

By default, pytest will not show test durations that are too small (<0.01s) unless ``-vv`` is
passed on the command-line.

To the end of the blurb in https://docs.pytest.org/en/latest/usage.html?highlight=durations#profiling-test-execution-duration would be enough.

Comment thread src/_pytest/runner.py
Comment thread changelog/4063.trivial.rst Outdated
@@ -0,0 +1 @@
Exclude 0.00 second entries from ``--duration`` output.

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.

please complete with ... output, unless ``-vv`` is passed on the command-line.

Comment thread src/_pytest/runner.py Outdated
dlist = dlist[:durations]

for rep in dlist:
if verbose < 2 and rep.duration < 0.01:

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.

should this take into account rounding (< 0.005 or whatever?)

is 0.009 displayed as 0.01? (I don't know, this could be fine already!)

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.

It uses 02.2f for formatting:

>>> '%02.2fs' % 0.009
'0.01s'

So I think this is fine as is. 👍

@asottile asottile Oct 8, 2018

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.

wouldn't that mean it isn't fine since it's not displayed as 0.00s?

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.

Oh duh you are right, sorry.

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.

it's certainly an edge case of an edge case though 😆

@nicoddemus

Copy link
Copy Markdown
Member

Thanks a lot @jeffreyrack, appreciate it!

@nicoddemus nicoddemus merged commit 9fb305b into pytest-dev:master Oct 14, 2018
@jeffreyrack jeffreyrack deleted the 4063-exclude-0-durations branch April 3, 2019 17:55
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.

5 participants