You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Writing unit tests can be slow because you need to create the unit test stubs to exercise the hamilton functionality you just wrote.
Describe the solution you'd like
You write your hamilton python functions.
You use a command line (e.g. hamilton create_tests MODULE_NAME.py) to create pytest style unit test stubs for all (or a subset) of the hamilton functions within that module.
The command line should append to an existing test_MODULE_NAME.py file if it exists.
The command line should skip functions that already have tests defined for them.
E.g. take a function like:
defspend_per_signup(spend: pd.Series, signups: pd.Series) ->pd.Series:
"""The cost per signup in relation to spend."""returnspend/signups
and then in the unit test file create something like:
deftest_spend_per_signup() ->pd.Series:
spend: pd.Series=pd.Series([]) # TODO: fill insignups: pd.Series=pd.Series([]) # TODO: fill inexpected=pd.Series([]) # TODO: fill inactual=module_name.spend_per_signup(spend, signups)
# because we're comparing pandas we should use the pandas testing modulepd.testing.assert_series_equal(actual, expected)
# if it wasn't comparing pandas we'd instead doassertactual==expected
Describe alternatives you've considered
Doing this manually.
Additional context
Most people don't like writing unit tests. We can at least speed up the process with such a tool.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Writing unit tests can be slow because you need to create the unit test stubs to exercise the hamilton functionality you just wrote.
Describe the solution you'd like
E.g. take a function like:
and then in the unit test file create something like:
Describe alternatives you've considered
Doing this manually.
Additional context
Most people don't like writing unit tests. We can at least speed up the process with such a tool.
The text was updated successfully, but these errors were encountered: