Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (48 sloc) 1.503 kb
733c684 @colinhowe Setup.py joy
authored
1 # Script loving influenced by the Pinax test running script
2 import optparse
3 import os
4 import sys
5
6 from django.conf import settings
7 from django.core.management import call_command
8
9 def setup_test_environment():
10 os.environ['PYTHONPATH'] = os.path.abspath(__file__)
11
12 settings.configure(**{
13 "DATABASE_ENGINE": "sqlite3",
14 "INSTALLED_APPS": ("modelversions", ),
15 })
16
17
18 def main():
19
20 usage = "%prog [options]"
21 parser = optparse.OptionParser(usage=usage)
22
23 parser.add_option("-v", "--verbosity",
24 action = "store",
25 dest = "verbosity",
26 default = "0",
27 type = "choice",
28 choices = ["0", "1", "2"],
29 help = "verbosity level; 0=minimal output, 1=normal output, 2=all output",
30 )
31 parser.add_option("--coverage",
32 action = "store_true",
33 dest = "coverage",
34 default = False,
35 help = "hook in coverage during test suite run and save out results",
36 )
37
38 options, _ = parser.parse_args()
39
40 if options.coverage:
41 try:
42 import coverage
43 except ImportError:
44 sys.stderr.write("coverage is not installed.\n")
45 sys.exit(1)
46 else:
47 cov = coverage.coverage(auto_data=True)
48 cov.start()
49 else:
50 cov = None
51
52 setup_test_environment()
53
54 call_command("test", verbosity=int(options.verbosity))
55
56 if cov:
57 cov.stop()
58 cov.save()
59
60
61 if __name__ == "__main__":
62 main()
Something went wrong with that request. Please try again.