Skip to content

Instantly share code, notes, and snippets.

@ktaragorn
Created October 23, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktaragorn/183aa1a1134828853501 to your computer and use it in GitHub Desktop.
Save ktaragorn/183aa1a1134828853501 to your computer and use it in GitHub Desktop.
Invoke tasks.py file to cover basic tasks - install packages and test/automated tests
from invoke import run, task
from invoke.exceptions import Failure
@task
def test():
run("python -m unittest discover test")
@task
def freeze():
run("pip freeze > requirements.txt")
@task(post=[freeze])
def install(pkg, upgrade=False):
upgrade = "--upgrade" if upgrade else ""
run("pip install " + pkg + " " + upgrade, pty=True)
@task(post=[freeze])
def uninstall(pkg):
run("pip uninstall " + pkg, pty=True)
@task
def setup():
run("pip install -r requirements.txt", pty=True)
@task
def rerun():
try:
return run("rerun -xp '**/*.py' invoke test").exited
except Failure as e:
print "The tool rerun isnt installed, installing it now, please try again."
run("gem install rerun --no-ri --no-rdoc")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment