Skip to content

Commit 6ad9571

Browse files
authored
add --co option to collect-only (#6116)
add --co option to collect-only
2 parents 3b24340 + 4946cc8 commit 6ad9571

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

changelog/6116.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``--co`` as a synonym to ``--collect-only``.

src/_pytest/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def pytest_addoption(parser):
109109
group.addoption(
110110
"--collectonly",
111111
"--collect-only",
112+
"--co",
112113
action="store_true",
113114
help="only collect tests, don't execute them.",
114115
),

testing/test_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def pytest_collect_file(path, parent):
402402
)
403403
testdir.mkdir("sub")
404404
testdir.makepyfile("def test_x(): pass")
405-
result = testdir.runpytest("--collect-only")
405+
result = testdir.runpytest("--co")
406406
result.stdout.fnmatch_lines(["*MyModule*", "*test_x*"])
407407

408408
def test_pytest_collect_file_from_sister_dir(self, testdir):
@@ -433,7 +433,7 @@ def pytest_collect_file(path, parent):
433433
p = testdir.makepyfile("def test_x(): pass")
434434
p.copy(sub1.join(p.basename))
435435
p.copy(sub2.join(p.basename))
436-
result = testdir.runpytest("--collect-only")
436+
result = testdir.runpytest("--co")
437437
result.stdout.fnmatch_lines(["*MyModule1*", "*MyModule2*", "*test_x*"])
438438

439439

0 commit comments

Comments
 (0)