Skip to content

Commit 81e5ab9

Browse files
benjelloMattiSG
authored andcommitted
Doc neutralize variable in YAML test
Related to openfisca/openfisca-core#1021
1 parent c1eaa94 commit 81e5ab9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

source/coding-the-legislation/writing_yaml_tests.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,32 @@ Values can be arithmetic expressions too.
181181

182182
You can find examples of YAML tests of tax and benefit systems with reforms applied on the [country template](https://github.com/openfisca/country-template/tree/main/openfisca_country_template/tests/reforms).
183183

184+
### Testing formulas using neutralized variables
185+
186+
A neutralized variable in a YAML test will return its default value when computed.
187+
188+
This is useful for example when you're testing a [reform](../key-concepts/reforms.md) of the [tax benefit system](../key-concepts/tax_and_benefit_system.md), allowing you to focus on the effects of the specific domains of the reform, [all other things being equal](https://en.wikipedia.org/wiki/Ceteris_paribus).
189+
190+
```yaml
191+
- name: "Result outside neutralized variables"
192+
period: 2021-01
193+
neutralized_variables:
194+
- housing_allowance
195+
input:
196+
age: 30
197+
output:
198+
basic_income: 600
199+
200+
- name: "Result within neutralized variables"
201+
period: 2021-01
202+
neutralized_variables:
203+
- basic_income
204+
input:
205+
age: 30
206+
output:
207+
basic_income: 0
208+
```
209+
184210
## Running a test
185211

186212
To run YAML tests, use the command line tool `openfisca test`, documented [here](../../openfisca-python-api/openfisca_test):

0 commit comments

Comments
 (0)