diff options
| author | Vo Minh Thu <vmt@openerp.com> | 2013-01-23 17:36:41 +0100 |
|---|---|---|
| committer | Vo Minh Thu <vmt@openerp.com> | 2013-01-23 17:36:41 +0100 |
| commit | 6e9025cbea1040ac67058f4b5cfd51d2e20832fd (patch) | |
| tree | f7624e15436e6d28e1e7a90f1d558710c276371b /openerpcommand/initialize.py | |
| parent | e2d5e0df9e47e836cab143d1b77b0d253d1df4b8 (diff) | |
[IMP] oe initialize: added --coverage flag.
bzr revid: vmt@openerp.com-20130123163641-uumkklqpaxkyvsr8
Diffstat (limited to 'openerpcommand/initialize.py')
| -rw-r--r-- | openerpcommand/initialize.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/openerpcommand/initialize.py b/openerpcommand/initialize.py index 3393c9a02d4..34c188bd583 100644 --- a/openerpcommand/initialize.py +++ b/openerpcommand/initialize.py @@ -70,8 +70,19 @@ def run(args): else: module_names = ['base'] + if args.coverage: + import coverage + # Without the `include` kwarg, coverage generates 'memory:0xXXXXX' + # filenames (which do not exist) and cause it to crash. No idea why. + cov = coverage.coverage(branch=True, include='*.py') + cov.start() openerp.netsvc.init_logger() registry = install_openerp(args.database, not args.no_create, module_names, not config['without_demo']) + if args.coverage: + cov.stop() + cov.html_report(directory='coverage') + # If we wanted the report on stdout: + # cov.report() # The `_assertion_report` attribute was added on the registry during the # OpenERP 7.0 development. @@ -99,5 +110,9 @@ def add_parser(subparsers): ' (use the `run-tests` command to choose specific' ' tests to run against an existing database).' ' Demo data are installed.') + parser.add_argument('--coverage', action='store_true', + help='report code coverage (particularly useful with --tests).' + ' The report is generated in a coverage directory and you can' + ' then point your browser to coverage/index.html.') parser.set_defaults(run=run) |
