-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Conversation
Love this - thanks @chusloj ! |
I've found that changing the |
@chusloj this is really elegant! One thing to make it easier is adding a fixture that does import pytest
@pytest.fixture
def skip_jit(monkeypatch):
monkeypatch.setenv("TESTING", "True")
yield
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) The |
@hdoupe Thanks very much for that suggestion! I was wondering how to fit the |
No problem @chusloj! |
Thanks for improving our testing capabilities, @chusloj! Merging now. |
This PR addresses a problem that @jdebacker had with creating unit tests for
calcfunctions.py
without decorators (#2489).Using
pytest
with functions incalcfunctions.py
is possible if theiterate_jit
decorator is removed, so the decorator will now simply return the passed function with no wrapper if the OS environment variable forTESTING
is set to'True'
(as a string, the environment variable only accepts strings) intest_calcfunctions.py
.The test function
test_DependentCare()
provided in #2489 passes with this change.This also enables unit testing discussed in #2419.