- 上传者: Administrator
- 上传时间:2024年02月24日 06时41分51秒
Tagged python test** Odoo allows you to highlight selections and run test cases. Decorator for tagging Points BaseCase objects. The tags are placed in ......
Tagged python test
Odoo allows you to highlight selections and run test cases. Decorator for tagging Points BaseCase objects. The tags are placed in a set accessible through the "test_tags" property. The tagged() decorator can be used on the test class to add or remove tags when assembling the test. Additionally, the decorator's assertion is that the tag name is a string. Tags are not picked up when using class inheritance. Of course, the tests will run once the comparison module is introduced. Instead of tracking module installations directly, you can also adjust your experiment to track all installed modules.
Some special tags are listed below:
At_install - Testing is done immediately after module setup and before various module rollouts. This is a standard implicit tag.
Post_install - It means that tests will be run after all modules are installed. This is mainly needed for HttpCase tests.
Standard - All Odoo tests that acquire from BaseCase are explicitly flagged by default. --test-tags also defaults to standard. So untagged tests naturally run.
Post_install is usually paired with -at_install when tagging test classes.
Subclasses of odoo.tests.common.BaseCase (usually by TransactionCase, SavepointCase, or HttpCase) are automatically marked standard and at_install by default.
Instead of adding or selecting tags, you can prefix them with a minus sign (-) to remove them. If you don't want your tests to run by default, you can remove the default tag.
# -*- coding: utf-8 -*-
from odoo.tests import TransactionCase, tagged
@tagged('-standard', 'mytest')
class MyTest(TransactionCase):
This test is not selected by default. To run, you have to explicitly select the corresponding tag (mytest).
Invocation
You can use --test-tags to select/filter which tests to run on the command line. It means --test-enable, so you don't need to specify --test-enable when using --test-tags.
This option is set to +standard by default. This means that tests tagged as standard (explicit or implicit) are run by default when Odoo is started with --test-enable.
Command to run test cases with test tags:
odoo-bin --test-tags [-][tag][/module][:class][.method]
The ‘-’ indicates to include or exclude tests conforming to this specification. This tag matches tags added to the class using the tagged() decorator.
Example:
● odoo-bin --test-tags /purchase
For testing the module.
● odoo-bin --test-tags mytest,standard
For testing specific tag.Configuration switch parameters also accept + and - prefixes. The - (minus) prefix is used to deselect test tags that have a previous tag, regardless of whether they are selected by other specified tags. For example, if you have a standard test that is also marked as mytest, you can run all standard tests except mytest.
● odoo-bin --test-tags .test_date_planned
For testing specific function with a unique name. This is equivalent to:
odoo-bin --test-tags /purchase:TestPurchase.test_date_planned
● odoo-bin --test-tags '/purchase,-slow'
Run the tests from the purchase module but not the ones tagged as slow:
● odoo-bin --test-tags '-standard, mytest, /student
Run only the tests from student or tagged as mytest
- 微信扫一扫,一分也是爱:
服务原则及地区范围
宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。
我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!
通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。
宜兴地区提供上门服务:
- 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
- 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。