Skip to content

Commit

Permalink
More comment
Browse files Browse the repository at this point in the history
  • Loading branch information
benjello committed Sep 9, 2021
1 parent a820af9 commit 94f6906
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions openfisca_core/tools/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def import_yaml():
return yaml, Loader


#: These keys the syntax keys for writing YAML tests.
#:
#: .. seealso::
#: For more information on common keys and examples, please take a look at
#: the official documentation on `Writing YAML tests`_.
#:
#: .. _Writing YAML tests: https://openfisca.org/doc/coding-the-legislation/writing_yaml_tests.html
#:
TEST_KEYWORDS = {
'absolute_error_margin',
'description',
Expand All @@ -40,7 +48,7 @@ def import_yaml():
'keywords',
'max_spiral_loops',
'name',
'neutralized_variables',
'neutralize_variables',
'only_variables',
'output',
'period',
Expand Down Expand Up @@ -156,7 +164,7 @@ def runtest(self):
self.baseline_tax_benefit_system,
self.test.get('reforms', []),
self.test.get('extensions', []),
self.test.get('neutralized_variables', [])
self.test.get('neutralize_variables', [])
)

builder = SimulationBuilder()
Expand Down Expand Up @@ -282,16 +290,16 @@ def pytest_collect_file(self, parent, path):
options = self.options)


def _get_tax_benefit_system(baseline, reforms, extensions, neutralized_variables):
def _get_tax_benefit_system(baseline, reforms, extensions, neutralize_variables):
if not isinstance(reforms, list):
reforms = [reforms]
if not isinstance(extensions, list):
extensions = [extensions]
if not isinstance(neutralized_variables, list):
neutralized_variables = [neutralized_variables]
if not isinstance(neutralize_variables, list):
neutralize_variables = [neutralize_variables]

# keep reforms order in cache, ignore extensions order
key = hash((id(baseline), ':'.join(reforms), frozenset(extensions), ':'.join(neutralized_variables)))
key = hash((id(baseline), ':'.join(reforms), frozenset(extensions), ':'.join(neutralize_variables)))
if _tax_benefit_system_cache.get(key):
return _tax_benefit_system_cache.get(key)

Expand All @@ -304,7 +312,7 @@ def _get_tax_benefit_system(baseline, reforms, extensions, neutralized_variables
current_tax_benefit_system = current_tax_benefit_system.clone()
current_tax_benefit_system.load_extension(extension)

for neutralized_variable in neutralized_variables:
for neutralized_variable in neutralize_variables:
current_tax_benefit_system.neutralize_variable(neutralized_variable)

_tax_benefit_system_cache[key] = current_tax_benefit_system
Expand Down

0 comments on commit 94f6906

Please sign in to comment.