Skip to content

Commit 15ef168

Browse files
authored
Merge pull request #4962 from blueyed/test_report_collect_after_half_a_second
tests: add test_report_collect_after_half_a_second
2 parents 832cef9 + cc6e5ec commit 15ef168

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/_pytest/terminal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from _pytest.main import EXIT_TESTSFAILED
2727
from _pytest.main import EXIT_USAGEERROR
2828

29+
REPORT_COLLECTING_RESOLUTION = 0.5
30+
2931

3032
class MoreQuietAction(argparse.Action):
3133
"""
@@ -512,7 +514,7 @@ def report_collect(self, final=False):
512514
t = time.time()
513515
if (
514516
self._collect_report_last_write is not None
515-
and self._collect_report_last_write > t - 0.5
517+
and self._collect_report_last_write > t - REPORT_COLLECTING_RESOLUTION
516518
):
517519
return
518520
self._collect_report_last_write = t

testing/test_terminal.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,31 @@ def test_1():
142142
child.sendeof()
143143
child.kill(15)
144144

145+
def test_report_collect_after_half_a_second(self, testdir):
146+
"""Test for "collecting" being updated after 0.5s"""
147+
148+
testdir.makepyfile(
149+
**{
150+
"test1.py": """
151+
import _pytest.terminal
152+
153+
_pytest.terminal.REPORT_COLLECTING_RESOLUTION = 0
154+
155+
def test_1():
156+
pass
157+
""",
158+
"test2.py": "def test_2(): pass",
159+
}
160+
)
161+
162+
child = testdir.spawn_pytest("-v test1.py test2.py")
163+
child.expect(r"collecting \.\.\.")
164+
child.expect(r"collecting 1 item")
165+
child.expect(r"collecting 2 items")
166+
child.expect(r"collected 2 items")
167+
rest = child.read().decode("utf8")
168+
assert "2 passed in" in rest
169+
145170
def test_itemreport_subclasses_show_subclassed_file(self, testdir):
146171
testdir.makepyfile(
147172
test_p1="""

0 commit comments

Comments
 (0)