added a method to automate python converage in the django module
This commit is contained in:
parent
7ee75bef12
commit
eb66e2a1bf
1 changed files with 55 additions and 6 deletions
|
|
@ -62,7 +62,7 @@ def commandline(args="", workingdir=None):
|
|||
|
||||
|
||||
@task
|
||||
def manage(args="", workingdir=None):
|
||||
def manage(args="", workingdir=None, prefix=None, suffix=None):
|
||||
configuration = env.config
|
||||
|
||||
# changes the working directory to the djangoroot
|
||||
|
|
@ -71,12 +71,14 @@ def manage(args="", workingdir=None):
|
|||
with virtualenv():
|
||||
if workingdir:
|
||||
with cd(workingdir):
|
||||
fabcommand = "{djangoroot}/manage.py {args} " \
|
||||
fabcommand = "{prefix} {djangoroot}/manage.py {args} " \
|
||||
"--pythonpath='{djangoroot}' " \
|
||||
"--settings={djangosettings}".format(
|
||||
"--settings={djangosettings} {suffix}".format(
|
||||
prefix=prefix,
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,
|
||||
suffix=suffix
|
||||
)
|
||||
|
||||
if env.debug:
|
||||
|
|
@ -89,12 +91,14 @@ def manage(args="", workingdir=None):
|
|||
shell='/bin/bash')
|
||||
|
||||
with cd(configuration.paths.django.root):
|
||||
cmd = "{djangoroot}/manage.py {args} " \
|
||||
cmd = "{prefix} {djangoroot}/manage.py {args} " \
|
||||
" --pythonpath='{djangoroot}' " \
|
||||
"--settings={djangosettings}".format(
|
||||
"--settings={djangosettings} {suffix}".format(
|
||||
prefix=prefix,
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,)
|
||||
djangosettings=configuration.imports.settings,
|
||||
suffix=suffix)
|
||||
|
||||
if env.debug:
|
||||
print("command: with cd(%s)" % configuration.paths.django.root)
|
||||
|
|
@ -118,6 +122,51 @@ def manage(args="", workingdir=None):
|
|||
# shell='/bin/bash' in all uses of local!
|
||||
|
||||
|
||||
@task
|
||||
def coverage(args="help", workingdir=None, outputdir=None,
|
||||
report=True, html=True):
|
||||
"""
|
||||
helper method that uses the coverage package
|
||||
|
||||
TODO: test if coverage is installed and if it isn't give
|
||||
an error explaining the problem
|
||||
"""
|
||||
configuration = env.config
|
||||
|
||||
prefix = "coverage run"
|
||||
|
||||
suffix = ""
|
||||
|
||||
if report:
|
||||
suffix += "&& coverage report"
|
||||
|
||||
if html:
|
||||
suffix += "&& coverage html"
|
||||
|
||||
if outputdir:
|
||||
outputpath = outputdir
|
||||
|
||||
else:
|
||||
outputpath = "{projectroot}/share".format(
|
||||
projectroot=configuration.paths.project.root,
|
||||
outputdir=outputdir)
|
||||
|
||||
outputpath += "/htmlcov"
|
||||
suffix += " -d %s" % outputpath
|
||||
|
||||
if env.debug:
|
||||
print("args: %s" % args)
|
||||
print("workigindir: %s" % args)
|
||||
print("\noutput directory: %s" % outputdir)
|
||||
print("full output path: %s" % outputpath)
|
||||
print("\nis report: %s" % report)
|
||||
print("is html: %s" % html)
|
||||
print("\nprefix: %s" % prefix)
|
||||
print("suffix: %s" % suffix)
|
||||
|
||||
manage(args=args, workingdir=workingdir, prefix=prefix, suffix=suffix)
|
||||
|
||||
|
||||
@task
|
||||
def admin(args="help"):
|
||||
configuration = env.config
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue