Skip to content

Commit 594ed3f

Browse files
committed
Add documenation for "--querycount" parameter
1 parent 4562abe commit 594ed3f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/usage.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Additional command line options
2929
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3030
Fail tests that render templates which make use of invalid template variables.
3131

32+
33+
``--querycount`` - show top N tests with most queries
34+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35+
Show a list of top N tests which executed most queries. Use `--querycount=0`
36+
to display a list of all tests ordered by the number of queries executed.
37+
3238
Running tests in parallel with pytest-xdist
3339
-------------------------------------------
3440
pytest-django supports running tests on multiple processes to speed up test

tests/test_report.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_zero_queries():
1919
''')
2020

2121
result = django_testdir.runpytest_subprocess()
22-
assert 'tests with most queries' not in result.stdout.str()
22+
assert 'top tests with most queries' not in result.stdout.str()
2323

2424
def test_querycount_report_lines(self, django_testdir):
2525
django_testdir.create_test_module('''
@@ -52,14 +52,14 @@ def test_zero_queries():
5252
assert True
5353
''')
5454

55-
result = django_testdir.runpytest_subprocess('--querycount=3')
55+
result = django_testdir.runpytest_subprocess('--querycount=4')
5656
lines = result.stdout.get_lines_after(
57-
'*top 3 tests with most queries*'
57+
'*top 4 tests with most queries*'
5858
)
5959
assert 'test_two_queries' in lines[0]
6060
assert 'test_one_query' in lines[1]
6161
assert 'test_failed' in lines[2]
62-
assert 'test_zero_queries' not in result.stdout.str()
62+
assert 'test_zero_queries' in lines[3]
6363

6464
def test_report_all_lines_on_querycount_zero(self, django_testdir):
6565
django_testdir.create_test_module('''

0 commit comments

Comments
 (0)