-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple directories support, norecursedirs, passing args to pytest #11
Conversation
- This fixes the problem with catching duplicate watchdog events related to a single file modification if using remote NFS mounts.
…ge cwd. - Positional arguments are now passed directly to py.test executable and can be separated from options via the optional "--" - py.test subprocess no longer changes the current directory - Directories are now specified via --watch option (comma-separated), default is the current directory. - Added "-p" alias for "--poll"
This fixes the edge case when py.test arguments contained quoted strings with spaces, e.g.: ptw -- -m 'not slow'
This fixes the issue with some editors that do atomic saves via a temporary file and a subsequent move.
This all looks great! Thank you for putting this all together, @aldanor! Also, really clear PR message. I really appreciate the writeup. It set good expectations. And the example usage was helpful to envision these changes. I'm all ready to pull it in. Just address those few comments first. For convenience:
I can also bump the version and update the README after. |
Nevermind about Do you think we should also pass that argument to py.test? Otherwise, py.test might still run tests even though we're not listening for changes in those deeper directories. |
Renaming |
@joeyespo The |
…d by --) Also, make --ext a bit smarter by prepending the '.' automatically if need be.
@joeyespo CLI args fixed, you can try testing it now. What's remaining is event spooling, will hack on it now. |
@joeyespo Event spooling done:
I guess I'll have to add |
@aldanor |
Instead of using diff --git i/pytest_watch/watcher.py w/pytest_watch/watcher.py
index abe97f7..ebdaa2f 100644
--- i/pytest_watch/watcher.py
+++ w/pytest_watch/watcher.py
@@ -6,7 +6,7 @@
from .spooler import EventSpooler
-from colorama import Fore
+from colorama import Fore, Style
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
from watchdog.events import (FileSystemEventHandler, FileModifiedEvent,
@@ -60,7 +60,7 @@ def run(self, summary=None):
if self.auto_clear:
subprocess.call(CLEAR_COMMAND)
command = ' '.join(['py.test'] + self.args)
- highlight = lambda arg: Fore.LIGHTWHITE_EX + arg + Fore.CYAN
+ highlight = lambda arg: Style.BRIGHT + arg + Style.NORMAL
msg = 'Running pytest command: {}'.format(highlight(command))
if summary:
msg = 'Changes detected in files:\n{}\n\nRerunning pytest command: {}'.format( |
On Mac OS the spooling seems to cause problems.
|
@aldanor There's a lot of divergent subtle cases being handled in this PR. If it's getting too unwieldy, perhaps open a few different ones to address specific issues. I'm very ready to pull in most things in here, but until it's completely ready, the whole thing is held up. |
I got to my mac, will run the whole thing on it tonight. I'm actually thinking this whole thing needs a test suite... |
@joeyespo Yep I know.... it will be real hard for me to start going backwards and split it up because I have to use it on daily basis, which means I'll have to keep track of more than three versions now -- remote, local and multiple PR branches... :( I'd rather make this whole thing work. (the norecursedirs changes I can roll back -- that's the only truly questionable part which will need further effort and thought). |
@tarpas Fixed. OSX weirdness... |
@blueyed Fixed |
Anything else? |
Works without problems for me also with pytest testmon. Thanks for the On Wed, Jun 10, 2015 at 11:02 PM, Joe Esposito notifications@github.com
|
Yeah, it'd be kind of tough now. Oh well. Pulling this is now so we can move forward. We can fix up Many thanks, @aldanor 😃 |
Multiple directories support, norecursedirs, passing args to pytest
Thanks again, @aldanor for your fantastic work here. And for your patience :-) |
@joeyespo Np :) I think all the outstanding issues have been covered, everyone's happy? ( Btw, maybe it would make sense to move this thing over to http://github.com/pytest-dev? (seeing as pytest itself will move there soon) |
This one was one hell of a PR, more Python LOC than the original code :) |
I'm up for it if they are.
😃 |
What exactly is Linux-only? I'm mostly on OSX myself (occasionally on Linux) |
@aldanor Oops, meant Unix, not Linux. |
FYI released these changes today. Be sure to |
I believe this PR closes all outstanding issues (#5, #6, #7 and #8). If merged in, this probably calls for a version bump.
The README will probably need to be updated as well..
Options added / things modified:
--
are now passed as is topy.test
executable..tox
for example, the handler would get completely swamped by that (so a simple pattern matching insideon_any_event
is not going to cut it).KeyboardInterrupt
even if it was caught after the first test run and exit gracefully.FileModifiedEvent
andFileCreatedEvent
. This fixed the problem where duplicate watchdog events would be fired upon a single file modification if using remote NFS mounts on Linux.-p
alias to--poll
.--verbose
/--quiet
options.--no-spool
option to disable spooling.--ext
option will prepend extensions with periods if needed.An example using the new functionality:
ptw -v -p --no-spool --ignore=.tox,.git folder1 folder2 -- tests/*.py -svv