Skip to content

--deselect doesn't work with absolute paths #6751

Open
@bstaletic

Description

@bstaletic
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: selectionrelated to test selection from the command line

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions