Skip to content

Commit d156f92

Browse files
authored
Print the running time of each test (#1799)
* Print duration times for each test * Add pytest_resource_usage package to deps
1 parent 2bb6f43 commit d156f92

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dev = [
5050
"pytest-xdist",
5151
"virtualenv",
5252
"tox",
53+
"pytest_resource_usage",
5354
# Linting
5455
"isort",
5556
"pylint",

requirements/dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ colorama==0.4.6
6161
contourpy==1.1.1
6262
# via matplotlib
6363
coverage[toml]==7.3.1
64-
# via
65-
# coverage
66-
# pytest-cov
64+
# via pytest-cov
6765
cryptography==41.0.3
6866
# via
6967
# adal
@@ -170,7 +168,6 @@ pyjwt[crypto]==2.8.0
170168
# via
171169
# adal
172170
# msal
173-
# pyjwt
174171
pylint==3.0.1
175172
# via tlo (pyproject.toml)
176173
pyparsing==3.1.1
@@ -184,10 +181,13 @@ pyshp==2.3.1
184181
pytest==7.4.2
185182
# via
186183
# pytest-cov
184+
# pytest-resource-usage
187185
# pytest-xdist
188186
# tlo (pyproject.toml)
189187
pytest-cov==4.1.0
190188
# via tlo (pyproject.toml)
189+
pytest-resource-usage==1.0.0
190+
# via tlo (pyproject.toml)
191191
pytest-xdist==3.3.1
192192
# via tlo (pyproject.toml)
193193
python-dateutil==2.8.2

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Collection of shared fixtures"""
2+
import pkgutil
3+
24
import pytest
35

46
DEFAULT_SEED = 83563095832589325021
@@ -31,6 +33,10 @@ def pytest_collection_modifyitems(config, items):
3133
if "slow" in item.keywords:
3234
item.add_marker(skip_slow)
3335

36+
# skip if pytest_resource_usage is not installed
37+
if pkgutil.find_loader("pytest_resource_usage"):
38+
for item in items:
39+
item.add_marker(pytest.mark.report_duration)
3440

3541
def pytest_generate_tests(metafunc):
3642
if "seed" in metafunc.fixturenames:

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ deps =
2929
-r{toxinidir}/requirements/base.txt
3030
pytest
3131
pytest-cov
32+
pytest-resource-usage
3233
commands =
3334
{posargs:pytest --cov --cov-report=term-missing -vv tests}
3435

0 commit comments

Comments
 (0)