pytest-dev / pytest-dev/pytest

ini files looked in a directory when --pyargs is used

Open
#2,820 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Pytest (3.2.2) looks for configuration files on directories named on command line, even if --pyargs option is given to interpret them as Python package names.

Reproduction:

$ cd /tmp
$ git clone https://github.com/pytest-dev/pytest pytest
$ python3 -mpytest --pyargs pytest
===================================== test session starts =====================================
platform linux -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0
rootdir: /tmp/pytest, inifile: tox.ini
plugins: xdist-1.20.0, forked-0.2, timeout-1.0.0, faulthandler-1.3.0, cov-2.4.0, hypothesis-3.12.0
collected 0 items                                                                              

================================ no tests ran in 0.00 seconds =================================

It correctly collects 0 tests since an installed pytest package contains no tests. However, the rootdir above looks wrong to me, I would expect it to be /tmp. When --pyarg is given on the command line, the items listed should be considered as package names, not directory names.

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 python3 -mpytest --pyargs pytest from /tmp, then trace how command-line arguments are interpreted and how the root directory and ini file are selected. Done means package names passed with --pyargs are not treated as directories, the rootdir is /tmp, and a regression test covers the reported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.