joeyespo / pytest-watch

Local continuous test runner with pytest and watchdog.
MIT License
727 stars 52 forks source link

Directories passed to pytest-watch are also passed to pytest, but shouldn't be #130

Open adibsaad opened 1 year ago

adibsaad commented 1 year ago

When I run this command

python -m pytest_watch src/

I expect pytest-watch to run pytest without any additional args and for pytest-watch to watch the src/ directory. Instead, what happens is pytest-watch correctly only watches for changes in src/ but it runs the command py.test src/, making pytest only look for tests in src/, but it should just be running pytest without additional args.

Output from above command

+ python -m pytest_watch src/

[Tue Dec 20 18:49:33 2022] Running: py.test src/
============================================================================ test session starts ============================================================================
platform linux -- Python 3.7.13, pytest-7.1.3, pluggy-1.0.0
rootdir: [removed], configfile: pytest.ini
plugins: anyio-3.6.2, requests-mock-1.10.0, Faker-15.3.4
collected 0 items                                                                                                                                                           

=========================================================================== no tests ran in 0.04s ===========================================================================

This also happens when you pass additional pytest args, it just gets concatenated

+ python -m pytest_watch src/ -- tests/

[Tue Dec 20 18:52:09 2022] Running: py.test src/ tests/