Skip to content

Commit 2318608

Browse files
committed
formatted and change logged
1 parent da31059 commit 2318608

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

changelog_entry.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- bump: patch
2+
changes:
3+
added:
4+
- Unit test for GeneralEconomyTask.calculate_cliffs() and fixture for the test
5+
- Test for calculate_single_economy with cliff impacts

tests/country/test_us.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_us_macro_comparison():
2222

2323
sim.calculate_economy_comparison()
2424

25+
2526
def test_us_macro_cliff_impacts():
2627
from policyengine import Simulation
2728

@@ -31,13 +32,15 @@ def test_us_macro_cliff_impacts():
3132
reform={
3233
"gov.usda.snap.income.deductions.earned_income": {"2025": 0.05}
3334
},
34-
include_cliffs=True
35+
include_cliffs=True,
3536
)
3637

3738
result = sim.calculate_economy_comparison()
38-
cliff_impact = result.model_dump().get('cliff_impact')
39+
cliff_impact = result.model_dump().get("cliff_impact")
3940

40-
assert cliff_impact is not None, "Expected 'cliff_impact' to be present in the output."
41+
assert (
42+
cliff_impact is not None
43+
), "Expected 'cliff_impact' to be present in the output."
4144

4245
assert cliff_impact["baseline"]["cliff_gap"] > 0
4346
assert cliff_impact["reform"]["cliff_share"] > 0

tests/test_simulation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from copy import deepcopy
1212

1313
from policyengine import Simulation
14-
from policyengine.outputs.macro.single.calculate_single_economy import GeneralEconomyTask
14+
from policyengine.outputs.macro.single.calculate_single_economy import (
15+
GeneralEconomyTask,
16+
)
1517

1618

1719
class TestSimulation:
@@ -73,9 +75,10 @@ def test__given_dataset_without_time_period__does_not_set_time_period(
7375
== None
7476
)
7577

76-
7778
class TestCalculateCliffs:
78-
def test__calculates_correct_cliff_metrics(self, mock_simulation_with_cliff_vars):
79+
def test__calculates_correct_cliff_metrics(
80+
self, mock_simulation_with_cliff_vars
81+
):
7982

8083
task = object.__new__(GeneralEconomyTask)
8184
task.simulation = mock_simulation_with_cliff_vars

0 commit comments

Comments
 (0)