Using YAML#
For handling very complex objects, especially in the context of end-to-end (E2E) tests, it can be highly beneficial to store expectations in separate YAML files. This module provides helper methods to both dump expectations into a YAML string and load them from a YAML string.
Any expectation supported by this module can be converted into YAML using the expectation_to_yaml function. Let's take a look at an example:
The resulting yaml_string will have the following content:
| YAML | |
|---|---|
You can also load a YAML string back into expectation objects using the expectation_from_yaml function:
| Python | |
|---|---|
Keep in mind that the loaded expectation may not be exactly identical to the original one before dumping, but it will be functionally equivalent.