Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for unit tests without decorators #2515

Merged
merged 7 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)