Skip to content
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

Add --onexit option #28

Merged
merged 1 commit into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add --onexit option
This is useful in a Makefile, where Ctrl-C will not execute later
commands, and you want to restore settings from onfail, onpass etc.
  • Loading branch information
blueyed committed Nov 29, 2015
commit bec02c5c1138d0571bfdf03cd316a8eaf827e157
2 changes: 2 additions & 0 deletions pytest_watch/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--beforerun=<cmd> Run arbitrary command before tests are run.
--onpass=<cmd> Run arbitrary command on pass.
--onfail=<cmd> Run arbitrary command on failure.
--onexit=<cmd> Run arbitrary command when exiting.
--nobeep Do not beep on failure.
-p --poll Use polling instead of events (useful in VMs).
--ext=<exts> Comma-separated list of file extensions that trigger a
Expand Down Expand Up @@ -66,6 +67,7 @@ def main(argv=None):
onpass=args['--onpass'],
onfail=args['--onfail'],
beforerun=args['--beforerun'],
onexit=args['--onexit'],
poll=args['--poll'],
extensions=extensions,
args=pytest_args,
Expand Down
6 changes: 4 additions & 2 deletions pytest_watch/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def run(self, summary=None):


def watch(directories=[], ignore=[], auto_clear=False, beep_on_failure=True,
onpass=None, onfail=None, beforerun=None, poll=False, extensions=[],
args=[], spool=True, verbose=False, quiet=False):
onpass=None, onfail=None, beforerun=None, onexit=None, poll=False,
extensions=[], args=[], spool=True, verbose=False, quiet=False):
if not directories:
directories = ['.']
directories = [os.path.abspath(directory) for directory in directories]
Expand Down Expand Up @@ -145,6 +145,8 @@ def watch(directories=[], ignore=[], auto_clear=False, beep_on_failure=True,
observer.join()
except KeyboardInterrupt:
observer.stop()
if onexit:
os.system(onexit)


def samepath(left, right):
Expand Down