From 4946cc82825c277754979cf6ea995482e5b1e2d5 Mon Sep 17 00:00:00 2001 From: NNRepos <45516943+NNRepos@users.noreply.github.com> Date: Fri, 1 Nov 2019 22:01:37 +0200 Subject: [PATCH] Add --co option to collect-only Fix #5845 --- changelog/6116.improvement.rst | 1 + src/_pytest/main.py | 1 + testing/test_collection.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog/6116.improvement.rst diff --git a/changelog/6116.improvement.rst b/changelog/6116.improvement.rst new file mode 100644 index 000000000..4fc96ec77 --- /dev/null +++ b/changelog/6116.improvement.rst @@ -0,0 +1 @@ +Add ``--co`` as a synonym to ``--collect-only``. diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 843c5b5f7..b4261c188 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -109,6 +109,7 @@ def pytest_addoption(parser): group.addoption( "--collectonly", "--collect-only", + "--co", action="store_true", help="only collect tests, don't execute them.", ), diff --git a/testing/test_collection.py b/testing/test_collection.py index 259868357..83345d2c6 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -402,7 +402,7 @@ class TestCustomConftests: ) testdir.mkdir("sub") testdir.makepyfile("def test_x(): pass") - result = testdir.runpytest("--collect-only") + result = testdir.runpytest("--co") result.stdout.fnmatch_lines(["*MyModule*", "*test_x*"]) def test_pytest_collect_file_from_sister_dir(self, testdir): @@ -433,7 +433,7 @@ class TestCustomConftests: p = testdir.makepyfile("def test_x(): pass") p.copy(sub1.join(p.basename)) p.copy(sub2.join(p.basename)) - result = testdir.runpytest("--collect-only") + result = testdir.runpytest("--co") result.stdout.fnmatch_lines(["*MyModule1*", "*MyModule2*", "*test_x*"])