Skip to content

Commit 565158d

Browse files
authored
Merge pull request #2515 from chusloj/jason_test
Allow for unit tests without decorators
2 parents da900b1 + ecdcd61 commit 565158d

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

taxcalc/decorators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def iterate_jit(parameters=None, **kwargs):
243243
transforms the calc-style function into an apply-style function that
244244
can be called by Calculator class methods (see calculator.py).
245245
"""
246+
246247
if not parameters:
247248
parameters = []
248249

@@ -299,6 +300,9 @@ def wrapper(*args, **kwargs):
299300
wrapper function nested in make_wrapper function nested
300301
in iterate_jit decorator.
301302
"""
303+
if os.getenv('TESTING') == 'True': # os TESTING environment only accepts string arguments
304+
return func(*args, **kwargs)
305+
302306
in_arrays = []
303307
pm_or_pf = []
304308
for farg in all_out_args + in_args:

taxcalc/tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# convert all numpy warnings into errors so they can be detected in tests
1010
numpy.seterr(all='raise')
1111

12+
@pytest.fixture
13+
def skip_jit(monkeypatch):
14+
monkeypatch.setenv("TESTING", "True")
15+
yield
1216

1317
@pytest.fixture(scope='session')
1418
def tests_path():

taxcalc/tests/test_calcfunctions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import re
1010
import ast
1111
from taxcalc import Records # pylint: disable=import-error
12+
from taxcalc import calcfunctions
13+
import numpy as np
14+
import pytest
1215

1316

1417
class GetFuncDefs(ast.NodeVisitor):
@@ -161,3 +164,16 @@ def test_function_args_usage(tests_path):
161164
msg += 'FUNCTION,ARGUMENT= {} {}\n'.format(fname, arg)
162165
if found_error:
163166
raise ValueError(msg)
167+
168+
169+
def test_DependentCare(skip_jit):
170+
"""
171+
Tests the DependentCare function
172+
"""
173+
174+
test_tuple = (3, 2, 100000, 1, [250000, 500000, 250000, 500000, 250000],
175+
.2, 7165, 5000, 0)
176+
test_value = calcfunctions.DependentCare(*test_tuple)
177+
expected_value = 25196
178+
179+
assert np.allclose(test_value, expected_value)

0 commit comments

Comments
 (0)