Created
October 23, 2015 16:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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