Skip to content

Commit

Permalink
Merge pull request #2515 from chusloj/jason_test
Browse files Browse the repository at this point in the history
Allow for unit tests without decorators
  • Loading branch information
MattHJensen authored Jan 4, 2021
2 parents da900b1 + ecdcd61 commit 565158d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions taxcalc/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def iterate_jit(parameters=None, **kwargs):
transforms the calc-style function into an apply-style function that
can be called by Calculator class methods (see calculator.py).
"""

if not parameters:
parameters = []

Expand Down Expand Up @@ -299,6 +300,9 @@ def wrapper(*args, **kwargs):
wrapper function nested in make_wrapper function nested
in iterate_jit decorator.
"""
if os.getenv('TESTING') == 'True': # os TESTING environment only accepts string arguments
return func(*args, **kwargs)

in_arrays = []
pm_or_pf = []
for farg in all_out_args + in_args:
Expand Down
4 changes: 4 additions & 0 deletions taxcalc/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# convert all numpy warnings into errors so they can be detected in tests
numpy.seterr(all='raise')

@pytest.fixture
def skip_jit(monkeypatch):
monkeypatch.setenv("TESTING", "True")
yield

@pytest.fixture(scope='session')
def tests_path():
Expand Down
16 changes: 16 additions & 0 deletions taxcalc/tests/test_calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import re
import ast
from taxcalc import Records # pylint: disable=import-error
from taxcalc import calcfunctions
import numpy as np
import pytest


class GetFuncDefs(ast.NodeVisitor):
Expand Down Expand Up @@ -161,3 +164,16 @@ def test_function_args_usage(tests_path):
msg += 'FUNCTION,ARGUMENT= {} {}\n'.format(fname, arg)
if found_error:
raise ValueError(msg)


def test_DependentCare(skip_jit):
"""
Tests the DependentCare function
"""

test_tuple = (3, 2, 100000, 1, [250000, 500000, 250000, 500000, 250000],
.2, 7165, 5000, 0)
test_value = calcfunctions.DependentCare(*test_tuple)
expected_value = 25196

assert np.allclose(test_value, expected_value)

0 comments on commit 565158d

Please sign in to comment.