Running tagged Python test cases
When you run the Odoo server with the --test-enabled
module, the test cases run immediately after the module is installed. If you want to run a test case after the installation of all the modules, or if you just want to run a test case for only one module, a tagged()
decorator is the answer. In this recipe, we will illustrate how to use this decorator to mold test cases.
Getting ready
For this recipe, we will be using the my_library
module from the last recipe. We will modify the sequence of the test case.
How to do it...
Follow these steps to add tags to the Python test cases:
- Add a
tagged()
decorator (such as the following) to the test class to run it after the installation of all modules:from odoo.tests.common import TransactionCase, tagged @tagged('-at_install', 'post_install') class TestBookState(TransactionCase): ...
- After that, run the test case as follows, just like before:
./odoo-bin -c server.conf...