pytest-dev / pytest-dev/pytest

Test selection syntax is baroque and foreign

Open
#2,193 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection type: enhancement
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

When I want to run a single test, I have to use an odd double-colon syntax:

$ pytest tests/test_api.py::ReportIncludeOmitTest::test_include

Double-colons appear nowhere in Python. If the test fails, pytest even reports the failure to me using the usual single-dot syntax:

=================================== FAILURES ===================================
______________________ ReportIncludeOmitTest.test_include ______________________

Please allow the more usual single-dot syntax, and perhaps a single colon between file and class?

$ pytest tests/test_api.py:ReportIncludeOmitTest.test_include

Versions:

$ pytest --version
This is pytest version 3.0.5, imported from /usr/local/virtualenvs/coverage/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
  pytest-xdist-1.15.0 at /usr/local/virtualenvs/coverage/lib/python2.7/site-packages/xdist/boxed.py
  pytest-xdist-1.15.0 at /usr/local/virtualenvs/coverage/lib/python2.7/site-packages/xdist/looponfail.py
  pytest-xdist-1.15.0 at /usr/local/virtualenvs/coverage/lib/python2.7/site-packages/xdist/plugin.py
  pytest-warnings-0.2.0 at /usr/local/virtualenvs/coverage/lib/python2.7/site-packages/pytest_warnings/__init__.pyc

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pytest's command-line test-selection entry point and compare the current double-colon syntax with the proposed single-dot and single-colon forms shown in the issue. Done means the proposed selectors work while existing syntax remains supported, with failures reported consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.