-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add ability to parse dicts of dicts in JSON to pass kwargs. #22
Conversation
Hey sorry this had fallen off my radar completely. Apologies for that. I will look at it shortly. |
if isinstance(value, dict): | ||
add_test(test_name, func, **value) | ||
else: | ||
add_test(test_name, func, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks simple and useful, although it may break backwards compatibility.
Can you illustrate with an example/test case in test_example.py
?
Thanks for your contribution, and apologies again for the very late reply. |
I've pulled in the changes from your master branch and updated my modifications to fit in with your refactored code. Thanks for taking the time to review the changes. I've also added a test case using a dict-of-dicts specified in a JSON file to specify kwargs to a test function. The rest of the test cases continue to pass. |
Any news? |
Add ability to parse dicts of dicts in JSON to pass kwargs.
Thanks. |
Great, thanks ! |
Super-late to the party. I have an older library using version 1.0.0 that I want to update. This change broke the contract for |
I have test functions with a large number of arguments:
Using the current version of ddt I can write my test cases as a dict of lists in JSON and get reasonably predictable automatically generated test names:
Due to the large number of arguments involved it rapidly becomes confusing mapping each argument value in the list to each named argument in the test function and it also makes refactoring the test function (specifically reordering the arguments) near impossible.
I have added a few lines to ddt which check whether the test arguments are a dict and passes them to the test function as kwargs rather than assuming they will always be a list and passing them as args. This allows me to specify my test cases as a dict of dicts in JSON with named arguments while retaining predictable test case names and allowing the reordering of arguments in the test function: