1- # -*- coding: utf-8 -*-
2-
3-
41import numpy as np
52
63from openfisca_core .periods import MONTH
7- from openfisca_core .simulation_builder import SimulationBuilder
84from openfisca_core .variables import Variable
95from openfisca_core .formula_helpers import switch
10- from openfisca_country_template import CountryTaxBenefitSystem
116from openfisca_country_template .entities import Person
127
138from pytest import fixture , approx
@@ -59,9 +54,9 @@ def formula(person, period):
5954 return result
6055
6156
62- # TaxBenefitSystem instance declared after formulas
63- our_tbs = CountryTaxBenefitSystem ()
64- our_tbs .add_variables (choice , uses_multiplication , uses_switch , returns_scalar )
57+ @ fixture ( scope = "module" , autouse = True )
58+ def add_variables_to_tax_benefit_system ( tax_benefit_system ):
59+ tax_benefit_system .add_variables (choice , uses_multiplication , uses_switch , returns_scalar )
6560
6661
6762@fixture
@@ -70,10 +65,9 @@ def month():
7065
7166
7267@fixture
73- def simulation (month ):
74- builder = SimulationBuilder ()
75- builder .default_period = month
76- simulation = builder .build_from_variables (our_tbs , {'choice' : np .random .randint (2 , size = 1000 ) + 1 })
68+ def simulation (simulation_builder , tax_benefit_system , month ):
69+ simulation_builder .default_period = month
70+ simulation = simulation_builder .build_from_variables (tax_benefit_system , {'choice' : np .random .randint (2 , size = 1000 ) + 1 })
7771 simulation .debug = True
7872 return simulation
7973
0 commit comments