← Back to team overview

openerp-expert-framework team mailing list archive

Re: Tests : how to ?

 

Hi,

TeMPO Consulting team has made a patch to do this. I'm not sure it works
with 6.1, but the patch is not very complicated, so it can be updated
easily.

You'll find it on the attachment of this email.

Best wishes

Quentin THEURET
TeMPO Consulting

Le 21/05/2012 15:46, Thibaut DIRLIK a écrit :
> Hi,
>
> I'm trying to write a test and run it for one of my module. This module is
> used by a lot of others, so if I could avoid to update it every time I need
> to run the tests, it would be fine (because it would update all modules
> which rely on it...). With --test-file, it doesn't work : created record
> (in the test file) are not found when referenced later in the file.
>
> So here is my question : how can I run a test file normally without
> updating all the module ?
>
> Thank you,
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-expert-framework
> Post to     : openerp-expert-framework@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-expert-framework
> More help   : https://help.launchpad.net/ListHelp
=== modified file 'bin/addons/__init__.py'
--- bin/addons/__init__.py	2011-01-27 09:56:54 +0000
+++ bin/addons/__init__.py	2012-03-26 13:35:14 +0000
@@ -665,7 +665,7 @@
 
     def load_test(cr, module_name, id_map, mode):
         cr.commit()
-        if not tools.config.options['test_disable']:
+        if not tools.config.options['test_disable'] and (not tools.config.options['test_module'] or module_name in tools.config.options['test_module'].split(',')):
             try:
                 _load_data(cr, module_name, id_map, mode, 'test')
             except Exception, e:
@@ -776,6 +776,9 @@
             for kind in ('init', 'demo', 'update'):
                 if hasattr(package, kind):
                     delattr(package, kind)
+            
+        elif (hasattr(package, 'demo') or package.dbdemo) and tools.config.options['test_module'] and m in tools.config.options['test_module'].split(','):
+                load_test(cr, m, idref, mode)
 
         statusi += 1
 

=== modified file 'bin/tools/config.py'
--- bin/tools/config.py	2011-05-17 05:54:43 +0000
+++ bin/tools/config.py	2012-03-26 13:35:14 +0000
@@ -87,6 +87,7 @@
             'test_file' : False,
             'test_report_directory' : False,
             'test_disable' : False,
+            'test_module' : False,
             'test_commit' : False,
             'static_http_enable': False,
             'static_http_document_root': None,
@@ -169,6 +170,8 @@
         group.add_option("--test-report-directory", dest="test_report_directory", help="If set, will save sample of all reports in this directory.")
         group.add_option("--test-disable", action="store_true", dest="test_disable",
                          default=False, help="Disable loading test files.")
+        group.add_option("--test-module", dest="test_module",
+                         default=False, help="module to test")
         group.add_option("--test-commit", action="store_true", dest="test_commit",
                          default=False, help="Commit database changes performed by tests.")
         parser.add_option_group(group)
@@ -309,7 +312,7 @@
             'debug_mode', 'smtp_ssl', 'load_language',
             'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
             'list_db', 'xmlrpcs',
-            'test_file', 'test_disable', 'test_commit', 'test_report_directory',
+            'test_file', 'test_disable', 'test_commit', 'test_module', 'test_report_directory',
             'osv_memory_count_limit', 'osv_memory_age_limit',
         ]
 


References