Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
6380 Tampilan

[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).

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
How to run tests Diselesaikan
4
Apr 23
45829
0
Mar 15
3670
1
Mar 15
5508
0
Des 24
9449
3
Sep 24
21602