summaryrefslogtreecommitdiff
path: root/odoo/tools/config.py
diff options
context:
space:
mode:
authorChristophe Monniez <moc@odoo.com>2017-08-21 08:36:35 +0200
committerChristophe Monniez <moc@odoo.com>2018-01-18 13:20:37 +0100
commitb356b190338e3ee032b9e3a7f670f76468965006 (patch)
treef32b334a7a7a467646e778d9f93a70a262f5b626 /odoo/tools/config.py
parent079e1a0c312ea6ed66ed42676b25b6ac22db2b58 (diff)
[IMP] tests: Add the possibility to tag tests
Purpose: When running tests, all the tests for the installed/updated files are done. This commit adds a 'tagged' decorator that can be used to tag tests. Combined with a new 'test-tags' CLI option, it adds the ability to filter which tests are executed. For example, @tagged('slow') will add a tag 'slow' to the test. The CLI option 'test-tags="slow"' will only run tests tagged 'slow'. One can use prefixes to select cases with tags. '+' or no prefix means that the tests tagged with this tag are selected for execution. '-' prefix will exclude the tests tagged with this tag. Exclusion takes precedence over inclusion. Also, by default, all Odoo tests cases are tagged 'standard' and with the technical name of the module. This means that when selecting tests with the 'test-tags' parameter, if '-standard' is not specified, all tests tags are going to be executed. When tagging tests, one can remove such automatic tag by prefixing the tag name with '-'. E.g. @tagged('-standard') will remove the standard tag from the test. Another example, if one wants to test the 'sale' module alone, even without adding any 'tagged' decorator thos tests can be selected like that: --test-tags="sale" Tests are selected or deselected using a TagsSelector. When instanciated, a string is passed with comma separated tests selectors like '+slow,-standard'. When the 'check' method is called with a test as argument, it returns True or False if the test has to be executed or not.
Diffstat (limited to 'odoo/tools/config.py')
-rw-r--r--odoo/tools/config.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/odoo/tools/config.py b/odoo/tools/config.py
index 3191f3c61ca..86cfb8adbfb 100644
--- a/odoo/tools/config.py
+++ b/odoo/tools/config.py
@@ -161,6 +161,10 @@ class configmanager(object):
my_default=False, help="Enable unit tests.")
group.add_option("--test-commit", action="store_true", dest="test_commit",
my_default=False, help="Commit database changes performed by XML tests.")
+ group.add_option("--test-tags", dest="test_tags",
+ default=('+standard'),
+ help="Comma separated list of tags to filter which tests to excute")
+
parser.add_option_group(group)
# Logging Group
@@ -425,7 +429,7 @@ class configmanager(object):
'dev_mode', 'shell_interface', 'smtp_ssl', 'load_language',
'stop_after_init', 'logrotate', 'without_demo', 'http_enable', 'syslog',
'list_db', 'proxy_mode',
- 'test_file', 'test_enable', 'test_commit', 'test_report_directory',
+ 'test_file', 'test_enable', 'test_commit', 'test_report_directory', 'test_tags',
'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
'data_dir',
'server_wide_modules',