-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix -vv
overriding --durations-min
(#12938)
#13100
Changes from 6 commits
7e5c1b6
30e7ad9
61b4f7a
a811765
071bfb3
fba107a
0d077e6
5865cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed ``--durations-min`` argument not respected if ``-vv`` is used. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# mypy: allow-untyped-defs | ||
from __future__ import annotations | ||
|
||
from collections.abc import Sequence | ||
import dataclasses | ||
import importlib.metadata | ||
import os | ||
|
@@ -970,28 +971,44 @@ def test_calls_showall(self, pytester: Pytester, mock_timing) -> None: | |
pytester.makepyfile(self.source) | ||
result = pytester.runpytest_inprocess("--durations=0") | ||
assert result.ret == 0 | ||
|
||
tested = "3" | ||
for x in tested: | ||
for y in ("call",): # 'setup', 'call', 'teardown': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what the rationale for this comment is. It was added with |
||
for line in result.stdout.lines: | ||
if (f"test_{x}") in line and y in line: | ||
break | ||
else: | ||
raise AssertionError(f"not found {x} {y}") | ||
TestDurations.check_tests_in_output(result.stdout.lines, 2, 3) | ||
|
||
def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None: | ||
pytester.makepyfile(self.source) | ||
result = pytester.runpytest_inprocess("--durations=0", "-vv") | ||
assert result.ret == 0 | ||
TestDurations.check_tests_in_output(result.stdout.lines, 1, 2, 3) | ||
|
||
def test_calls_showall_durationsmin(self, pytester: Pytester, mock_timing) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test for |
||
pytester.makepyfile(self.source) | ||
result = pytester.runpytest_inprocess("--durations=0", "--durations-min=0.015") | ||
assert result.ret == 0 | ||
TestDurations.check_tests_in_output(result.stdout.lines, 3) | ||
|
||
def test_calls_showall_durationsmin_verbose( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the actual test that fails without the change in |
||
self, pytester: Pytester, mock_timing | ||
) -> None: | ||
pytester.makepyfile(self.source) | ||
result = pytester.runpytest_inprocess( | ||
"--durations=0", "--durations-min=0.015", "-vv" | ||
) | ||
assert result.ret == 0 | ||
TestDurations.check_tests_in_output(result.stdout.lines, 3) | ||
|
||
for x in "123": | ||
for y in ("call",): # 'setup', 'call', 'teardown': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking for |
||
for line in result.stdout.lines: | ||
if (f"test_{x}") in line and y in line: | ||
break | ||
else: | ||
raise AssertionError(f"not found {x} {y}") | ||
@staticmethod | ||
def check_tests_in_output( | ||
lines: Sequence[str], *expected_test_numbers: int | ||
) -> None: | ||
number_of_tests = 3 | ||
found_test_numbers = set( | ||
test_number | ||
for test_number in range(1, number_of_tests + 1) | ||
if any( | ||
line.endswith(f"test_{test_number}") and " call " in line | ||
for line in lines | ||
) | ||
) | ||
assert found_test_numbers == set(expected_test_numbers) | ||
|
||
def test_with_deselected(self, pytester: Pytester, mock_timing) -> None: | ||
pytester.makepyfile(self.source) | ||
|
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 only checks whether test 3 is in the output, but not if the other tests are not. Fixed this.