Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 115 lines (102 sloc) 3.766 kb
#!/usr/bin/env python
import sys
import libpry
def main():
from optparse import OptionParser, OptionGroup
parser = OptionParser(
usage = "%prog [options] [testfilter]",
version="%prog 0.1",
)
parser.add_option("-l", "--list",
action="store_true", dest="list",
help="List all tests.")
parser.add_option("-r", "--recurse",
action="store_true", dest="recurse", default=False,
help="Recurse through child directories.")
parser.add_option("-s", "--stats",
action="store_true", dest="stats",
help="Print coverage summary.")
parser.add_option("-n", "--benchmark",
action="store", dest="benchmark", type="int", default=1,
help="Run each test N times.")
parser.add_option("-q", "--quiet",
action="store_true", dest="quiet",
help="Quiet.")
parser.add_option("-v", "--verbose",
action="count", dest="verbose", default=1,
help="Increase verbosity. Can be passed multiple times.")
parser.add_option(
"--debug-dump",
action="store_true", dest="debug",
help="For debugging only. Like -l,"
" but dump the full tree structure."
)
group = OptionGroup(
parser,
"Profiling",
"Generating run profiles for unit tests."
)
group.add_option(
"-p", "--profile",
action="store_true", dest="profile",
help="Do a profiling run. Usually used"
" in conjunction with -n to specify multiple runs."
)
group.add_option(
"", "--profile-sort",
action="store", dest="profile_sort",
default="time", type="choice",
choices=[
"calls",
"cumulative",
"file",
"module",
"pcalls",
"line",
"name",
"nfl",
"stdname",
"time"
],
help="Profile result sorting key. "
"See Python documentation for pstats module."
)
parser.add_option_group(group)
(options, args) = parser.parse_args()
if not args:
path, pattern = ".", None
elif len(args) == 1:
path, pattern = libpry.utils._splitSpec(args[0])
else:
parser.error("Please pass only one argument.")
if options.stats:
coverage = True
else:
coverage = False
if options.quiet:
verbose = 0
else:
verbose = options.verbose
if options.profile:
p = options.profile_sort
else:
p = None
r = libpry.test._RootNode(coverage, p)
r.addPath(path or ".", options.recurse)
if pattern:
r.mark(pattern)
r.prune()
output = libpry.test._Output(r, verbose)
if options.list:
r.printStructure()
print "Total: %s"%len(r.tests())
sys.exit()
elif options.debug:
r.dump()
print "Total: %s"%len(r.tests())
sys.exit()
else:
r._run(output, options.benchmark)
output.final(r)
if __name__ == "__main__":
main()
Jump to Line
Something went wrong with that request. Please try again.