Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Why does the --test-file argument run tests in "no update" mode?

By
Alexandre Fayolle - Camptocamp
on 5/28/13, 6:13 AM 1,134 views

[question asked on the framework expert mailing list, but here may be a better place]

Given a module with a reasonable test suite made of several yaml test files, if I want to run a single test file, I have 2 options:

option 1: comment out all the file I don't want to run in __openerp__.py and run openerp with --test-enable -i mymodule

option 2: keep __openerp__.py as is, and use --test-enable --test-file /absolute/path/to/test.yml

I prefer something along the line of option 2, because it enables me to quickly run all the tests of the module without editing __openerp__.py (and it saves me from committing a modified __openerp__.py with most tests disabled). The problem is that tests run with option 2 will tend to fail, because this command line syntax causes the tests to be run in "no update" mode which means for instance that !workflow steps will do nothing.

I can change this locally with the following patch:

--- openerp/cli/server.py       2013-05-14 10:33:33 +0000
+++ openerp/cli/server.py       2013-05-27 14:16:54 +0000
@@ -105,7 +105,7 @@
         db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=config['init'] or config['update'])
         cr = db.cursor()
         _logger.info('loading test file %s', test_file)
-        openerp.tools.convert_yaml_import(cr, 'base', file(test_file),'test', {}, 'test', True)
+        openerp.tools.convert_yaml_import(cr, 'base', file(test_file),'test', {}, 'test', False)
         cr.rollback()
         cr.close()
     except Exception:

but I'm wondering about the reason of this hardcoded True value. The changes made by the tests are still rolled back with the patch applied and I believe that the only side effect I saw with the patch applied also exists without the patch (namely the incrementation of the various PostgreSQL sequences impacted by the tests).

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/28/13, 6:13 AM
Seen: 1134 times
Last updated: 3/16/15, 8:10 AM