← Back to team overview

openerp-expert-framework team mailing list archive

running a single test file

 

Hello,

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, AFAICT, 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.

I can change this locally with the following patch:

----------------------------8<-------------------------------
--- 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:
----------------------------8<-------------------------------

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.

Thanks for your insightful comments.

-- 
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://www.camptocamp.com