Comments (11)
This was done in ede80ff.
from pytest-watch.
Yeah, this was intended. (Was motivated by that commit and also to be consistent with --ignore
being forwarding to pytest from #48.)
Thinking more about it though. Here's the use cases I was thinking of:
-
Run from subdirectory, watching and collecting tests from all subdirectories:
- Formerly
ptw myproject -- myproject
- Currently
ptw myproject
- Formerly
-
Ignore unrelated dirs from watch and test collection (due to large trees slowing things down):
- Formerly
ptw --ignore tmp -- --ignore tmp
- Currently
ptw --ignore tmp
Or from a subdirectory:
- Formerly
ptw myproject --ignore myproject/tmp -- myproject --ignore myproject/tmp
- Currently
ptw myproject --ignore myproject/tmp
(This actually was never implemented, which I forgot about! Just opened #56 to address this.)
- Formerly
-
Include watched directories without collecting tests from them
- Formerly
ptw myproject mytests -- mytests
- Currently not possible (
ptw myproject mytests -- --ignore myproject
doesn't work)
- Formerly
-
Include test collection from a directory without watching them
- Formerly
ptw myproject -- myproject mytests
- Currently
ptw myproject -- mytests
- Formerly
(1)-(3) re-runs the tests when changing either source code or test files.
(4) only re-runs when changing source code, which doesn't seem that useful.
So the issue is that (3) isn't possible now. Is it really a problem though? It almost seems like a pre-optimization to try to exclude test collection from a watched directory. Remember, watchdog also has to crawl through a huge directory, so you'll have delay for huge project directories regardless. A better fix might be to exclude the things that aren't testable from both (static and template files for websites,vendor
directories, etc.)
Or is there another case I'm leaving out?
from pytest-watch.
I am using testpaths = path/to/tests
, so there is no need to pass path/to/tests
to py.test.
So with ptw path
, path
would be watched, but only path/to/tests
used to collect tests.
If you want to keep the current behavior, then the testpaths
option should be looked at and only if it's not used the watch directory should be passed explicitly to py.test
?
from pytest-watch.
So with ptw path, path would be watched, but only path/to/tests used to collect tests.
If you pass arguments to py.test
, does that overwrite testpaths
?
from pytest-watch.
Btw, I'm also considering having pytest-watch be usable as a standard pytest plugin. Making the command line arguments more consistent with pytest was a first step. (Just opened #57 to dedicate to that discussion.)
from pytest-watch.
If you pass arguments to py.test, does that overwrite testpaths?
Yes.
from pytest-watch.
Ah, that's a shame.
The idea is that ptw dir
is to tell both watchdog and pytest to start their search from there. Some more questions for you:
- Are you able to run
ptw
from your project root instead of specifying where to watch and where to collect tests? If not, is it because:- Your tests are located outside of the project?
- It's taking too long to boot?
- Are you able to run
cd dir && ptw
instead?
from pytest-watch.
Ah, that's a shame.
Only in this context, right? Because otherwise it's quite nice, isn't it?
While I could workaround this behaviour change, I'd rather not do so.. :)
Are you able to run ptw from your project root instead of specifying where to watch and where to collect tests?
Yes, but I'd like to avoid scanning everything (build dir, venv etc). Even the project's source can be skipped. That's why I like testpaths
.
Are you able to run cd dir && ptw instead?
Yes.
What speaks against using the same behaviour regarding testpaths
as py.test though?
from pytest-watch.
Only in this context, right? Because otherwise it's quite nice, isn't it?
Yeah. More like it's a shame that I overlooked that option / missed your use case. Was mostly asking these questions to make sure I didn't miss something else.
Thinking more about it, I suppose (3) is important after all to keep test runs lightning fast. Perhaps a new named argument could be used for watching without collecting tests. This would continue to make sense if pytest-watch was used as a pytest plugin.
As for the case you've pointed out, what do you think of having an equivalent config option pytest-watch? Say, watchpaths
under the [pytest-watch]
category. Like testpaths, it wouldn't have any effect when passing in <dir>
arguments. Then you could run ptw
with no arguments and fully customize what paths to watch and what paths to collect tests from.
from pytest-watch.
As for the case you've pointed out, what do you think of having an equivalent config option pytest-watch?
Sounds good to me!
from pytest-watch.
Just opened #61 to address this. Closing as per this comment, but feel free to re-open if you don't think that'll be enough to help you.
from pytest-watch.
Related Issues (20)
- broken link in the README: saythanks
- How to use with poetry? HOT 3
- Run ptw with -s HOT 3
- pytest watch seems to fail when pyproject.toml is used as a config file HOT 7
- Logging error when running pytest in pytest-watch HOT 1
- Integration with pytest-cov HOT 2
- My ptw doesn't "watch" subdirectories
- Running from "python -m pytest_watch" does not add current path to PYTHONPATH HOT 1
- ignore `Client.dataset is deprecated` warnings
- Maintenance Status? HOT 4
- pytest 7.0: AttributeError: 'dict' object has no attribute 'config' HOT 3
- error:'str' object has no attribute 'plate_num'
- Specify `python_requires` in the distribution package metadata
- Runner argument not parsed correctly on windows
- Error in Python 3.10: `module 'collections' has no attribute 'MutableSet'` HOT 5
- `ImportError` when running tests using `ptw` HOT 2
- Directories passed to pytest-watch are also passed to pytest, but shouldn't be
- sdist is missing LICENSE
- When I install pytest-watch with Python 3.11 and pip 22.3.1 I see deprecation warning HOT 1
- GO TO PYTEST-WATCHER HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-watch.