Skip to content

If a command line argument is a directory that contains a tox.ini file, that tox file is used #4009

@MattSable

Description

@MattSable

If you supply a command line argument that is a directory that contains a tox.ini file, that tox file gets used. Example layout and files that can reproduce this:

/tests
    conftest.py
    test.py
/some_folder
    tox.ini

conftest.py

def pytest_addoption(parser):
    parser.addoption(
        "--foo"
    )

test.py

def test():
    print("Hello world!")

tox.ini

[pytest]
addopts = --collect-only

Running just pytest .\tests\test.py, I get the expected output:

============================= test session starts =============================
platform win32 -- Python 3.6.4, pytest-3.8.0, py-1.6.0, pluggy-0.7.1
rootdir: C:\Users\masable\Desktop\examples, inifile:
collected 1 item

tests\test.py .                                                          [100%]

========================== 1 passed in 0.03 seconds ===========================

If instead you run pytest .\tests\test.py --foo .\some_folder\, than the tox.ini in some_folder is used, and the output is:

============================= test session starts =============================
platform win32 -- Python 3.6.4, pytest-3.8.0, py-1.6.0, pluggy-0.7.1
rootdir: C:\Users\masable\Desktop\examples\some_folder, inifile: tox.ini
collected 1 item
<Module 'test.py'>
  <Function 'test'>

======================== no tests ran in 0.02 seconds =========================

I'm on pytest 3.8.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions