Odoo also supports a second type of tests, described using YAML data files. Originally all tests used YAML, until more recently the unittest based tests were introduced. While both are supported, and many core addons still include YAML tests, the official documentation currently does not mention the YAML tests. The last documentation on it is available at https://doc.odoo.com/v6.0/contribute/15_guidelines/coding_guidelines_testing/ .

Developers with a Python background will probably feel more at home with unittest, since it is a standard Python feature, while YAML tests are designed with Odoo-specific conventions. The trend clearly is to prefer unittest over YAML, and YAML support can be expected to be dropped in future versions.

For these reasons, we will not do an in-depth coverage of YAML tests. It might still be useful to have some basic understanding on how they work.

YAML tests are data files, similar to CSV and XML. In fact the YAML format was intended to be a more compact data format that can be used in place of XML. Unlike Python tests, where tests must be in a test/ subdirectory, the YAML test files can be anywhere inside the addon module. But frequently they will be inside a tests/ or test/ subdirectory. And while Python tests are automatically discovered, YAML tests must be declared in the __manifest__.py manifest file. This is done with the test key, similar to the data key we already know.

In Odoo 10 YAML tests are not used anymore, but here is an example, from the 02_order_to_invoice.yml in the point_of_sale addon module:

- 
  I click on the "Make Payment" wizard to pay the PoS order 
- 
  !record {model: pos.make.payment, id: pos_make_payment_2, context: '{"active_id": ref("pos_order_pos1"), "active_ids": [ref("pos_order_pos1")]}' }: 
    amount: !eval > 
        (450*2 + 300*3*1.05)*0.95 
- 
  I click on the validate button to register the payment. 
- 
  !python {model: pos.make.payment}: | 
    self.check(cr, uid, [ref('pos_make_payment_2')], context={'active_id': ref('pos_order_pos1')} ) 

The lines that begin with a ! are YAML tags, equivalent to the tag elements we find in XML files. In the preceding code we can see a !record tag, equivalent to the XML <record>, and a !python tag, that allows us to run Python code on a model, pos.make.payment in the example.

As you can see, YAML tests use a Odoo-specific syntax that needs learning. In comparison, Python tests use the existing unittest framework, only adding Odoo-specific wrapper classes like TransactionCase.