Development Book V17: Tagged python test

You may run test cases and highlight options in Odoo. Decorator for BaseCase objects with Points tagging. The "test_tags" field allows access to the set in which the tags are stored. When putting the test together, the tagged() decorator on the test class can be used to add or remove tags. The decorator further asserts that the tag name is a string. Tags are not detected when class inheritance is used. Naturally, as soon as the comparison module is introduced, the tests will begin. You can also modify your experiment to track all installed modules, rather than just module installations.

Some special tags are listed below:

Standard: Every Odoo test that is obtained from BaseCase has a verifiably standard tag. Standard is also the default value for --test-tags. This suggests that when tests are empowered, untagged tests will run automatically.

At_install: The test will be executed soon after the module establishment and before various modules are introduced. This is a default implicit tag.

Post_install: Implies that the test will be executed after every one of the modules are installed. You need this for HttpCase tests more often than not.

Post_install is usually paired with -at_install when tagging a test class.

Subclasses of odoo.tests.common.BaseCase (usually through TransactionCase, or HttpCase) are automatically tagged with standard and at_install by default.

Tags can be prefixed with the less (- ) sign, to eliminate them rather than add or select them. For example, in the event that you don't believe your test should be executed as a matter of course you can eliminate the standard tag:

# -*- coding: utf-8 -*-
                    from odoo.tests import TransactionCase, tagged
                    @tagged('-standard', 'external')
                    class MyTest(TransactionCase):

The test in the aforementioned example won't run by default. It must be expressly selected to run, and the relevant tag (external).


--test-tags can be utilized to select/filter tests to run on the command line. It suggests -- test-enable,so it's not important to determine -- test-enable while utilizing - - test-tags.

When starting Odoo with --test-enable, the option defaults to +standard meaning tests tagged standard (explicitly or implicitly) will be run by default.

Command to run the test cases using test-tags:

odoo-bin --test-tags [-][tag][/module][:class][.method]

  • The - specifies if we want to include or exclude tests matching this spec.
  • The tag will match tags added on a class with a tagged() decorator * will match all tags


  • If you want to test specific tag:
    odoo-bin --test-tags standard,external

    Both + and - prefixes are accepted in the configuration switch argument. Regardless of whether they are selected by other specified tags or not, the - (minus) prefix is designed to deselect test tags with this prefix. You can run all standard tests except for the external ones, for instance, in the unlikely event that there are standard tests that are also marked as external:

    odoo-bin --test-tags 'standard,-slow'
  • If you want to test the module:
    odoo-bin --test-tags /sale
  • If you want to test a specific function with a unique name:
    odoo-bin --test-tags .test_currency_post
  • Run the tests from the sale module but not the ones tagged as standard:
    odoo-bin --test-tags '/sale,-slow'
  • Run only the tests from sale or tagged as external:

    odoo-bin --test-tags '-standard, external, /sale’



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message