From c5c53e9259deb0da02022f8f7945f1a1de1dd323 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 23 Aug 2024 09:55:55 -0400 Subject: [PATCH] a couple other changes to avoid relying in a specific taxcalc version --- tests/test_get_micro_data.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/test_get_micro_data.py b/tests/test_get_micro_data.py index ff0a546..3e3e9e0 100644 --- a/tests/test_get_micro_data.py +++ b/tests/test_get_micro_data.py @@ -247,8 +247,6 @@ def test_get_data(baseline, dask_client): def test_taxcalc_advance(): """ Test of the get_micro_data.taxcalc_advance() function - - Note that this test may fail if the Tax-Calculator is not v 3.2.1 """ expected_dict = utils.safe_read_pickle( os.path.join(CUR_PATH, "test_io_data", "tax_dict_for_tests.pkl") @@ -256,27 +254,27 @@ def test_taxcalc_advance(): test_dict = get_micro_data.taxcalc_advance( 2028, {}, {}, "cps", None, None, 2014, 2028 ) - for k, v in test_dict.items(): - assert np.allclose(expected_dict[k], v, equal_nan=True) + # check that keys are the same + assert (set(expected_dict.keys()) == set(test_dict.keys())) + for _, v in test_dict.items(): + # check that test data returns some non-zero values + assert (np.count_nonzero(v) > 0) @pytest.mark.local def test_cap_inc_mtr(): """ Test of the get_micro_data.cap_inc_mtr() function - - Note that this test may fail if the Tax-Calculator is not v 3.2.1 """ calc1 = get_micro_data.get_calculator( calculator_start_year=2028, iit_reform={}, data="cps" ) calc1.advance_to_year(2028) - expected = np.genfromtxt( - os.path.join( - CUR_PATH, "test_io_data", "mtr_combined_capinc_for_tests.csv" - ), - delimiter=",", - ) test_data = get_micro_data.cap_inc_mtr(calc1) - assert np.allclose(expected, test_data, equal_nan=True) + # check that test data returns some non-zero values + assert (np.count_nonzero(test_data) > 0) + # assert mtrs < 1 + assert (test_data.max() < 1) + # assert mtrs > -1 + assert (test_data.min() > -1)