콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
6431 화면

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

아바타
취소
관련 게시물 답글 화면 활동
How to run tests 해결 완료
4
4월 23
45898
0
3월 15
3738
1
3월 15
5581
0
12월 24
9510
3
9월 24
21773