Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc neutralize variable in YAML test #252

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions source/coding-the-legislation/writing_yaml_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,32 @@ Values can be arithmetic expressions too.

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/master/openfisca_country_template/tests/reforms).

### Testing formulas using neutralized variables

A neutralized variable in a YAML test will return its default value when computed.

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 only on the effects of the specific domains of the reform, [all other things being equal](https://en.wikipedia.org/wiki/Ceteris_paribus).

```yaml
- name: "Result outside neutralized variables"
period: 2021-01
neutralized_variables:
- housing_allowance
input:
age: 30
output:
basic_income: 600

- name: "Result within neutralized variables"
period: 2021-01
neutralized_variables:
- basic_income
input:
age: 30
output:
basic_income: 0
```

## Running a test

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