pytest-dev / pytest-dev/pytest

`--deselect` doesn't work with absolute paths

Open
#6,751 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  • a detailed description of the bug or suggestion
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

I wanted to do something like pytest /path/to/project/tests/* --deselect /path/to/project/tests/test_needsToBeAvoided.py, but this didn't work. Instead I had to do pytest /path/to/project/tests/* --deselect tests/test_needsToBeAvoided.py.

bstaletic@Gallifrey pytest % pip list
Package               Version
--------------------- ----------
attrs                 19.3.0
beautifulsoup4        4.8.2
certifi               2019.11.28
chardet               3.0.4
codecov               2.0.15
coverage              5.0.3
entrypoints           0.3
flake8                3.7.9
flake8-comprehensions 3.2.2
flake8-ycm            0.1.0
idna                  2.8
mccabe                0.6.1
more-itertools        8.2.0
packaging             20.1
pip                   20.0.2
pluggy                0.13.1
psutil                5.6.7
ptvsd                 4.3.2
py                    1.8.1
pycodestyle           2.5.0
pyflakes              2.1.1
PyHamcrest            2.0.0
pyparsing             2.4.6
pytest                5.3.5
pytest-cov            2.8.1
requests              2.22.0
setuptools            41.2.0
six                   1.14.0
soupsieve             1.9.5
urllib3               1.25.8
waitress              1.4.3
wcwidth               0.1.8
WebOb                 1.8.6
WebTest               2.0.34
bstaletic@Gallifrey pytest % python -c 'print(__import__("pytest").__version__)'
5.3.5
bstaletic@Gallifrey pytest % cat /etc/os-release
NAME="Artix Linux"
PRETTY_NAME="Artix Linux"
ID=artix
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://www.artixlinux.org/"
DOCUMENTATION_URL="https://wiki.artixlinux.org/"
SUPPORT_URL="https://forum.artixlinux.org/"
BUG_REPORT_URL="https://gitea.artixlinux.org/"
LOGO=artixlinux

Steps to repro:

  • mkdir ~/test
  • cd ~/test
  • echo 'def test_test():assert 1' > test_test.py
  • pytest ~/test/*_test.py --deselect test_test.py - this works. The report says "1 test deselected".
  • pytest ~/test/*_test.py --deselect ~/test/test_test.py - this one doesn't work. The test is being run.
  • pytest . --deselect ~/test/test_test.py - this one doesn't work either. The test is being run.

Additional info:

I have encountered this with python 3.8.0 and 3.8.1. I have not tried any other version.

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 by reproducing the documented pytest commands using an absolute path with --deselect, then trace pytest's command-line deselection handling. Done means the absolute-path command reports the targeted test as deselected, matching the relative-path behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.