-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix: set DucktapeJSONEncoder as default encoder in reports. #251
base: master
Are you sure you want to change the base?
Fix: set DucktapeJSONEncoder as default encoder in reports. #251
Conversation
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.
Did one of the cases not using DucktapeJSONEncoder
cause a problem?
imo we should really only go one of two ways here. The current approach is that cases where we expect complex data structures that the json
module won't handle them naturally provide the override. This is used for cases where, e.g., we know we have a TestResult
which is a "real" class rather than just a dumb data container. The danger is that we might miss a case, but to date, I haven't heard of any issues with this.
The second would be to be very defensive and support the to_json
extension everywhere. If we wanted to do that, we should make it fully comprehensive -- in json_serializable.py
we should provide the type of wrapper you have here and use it universally, probably banning direct imports of json
everywhere else. That guarantees we cover not only the reporter, but also, e.g., result.py
, vagrant.py
, etc.
@ewencp Hi, Ewen
Currently, if you try to use object in @parametrize, test will fail. Namely, we use subclass of I suppose that it is possible to remove this restriction and add ability to user pass object with to_json overriden method to parameter.
So you suggests to move my helper function to distinct module and use it everywhere? Ok, sounds good for me. |
@ewencp Hi, I changed my PR as you suggested (second variant). Could you please look at it again? |
pardon my trigger finger :) |
I'm not super familiar with all of ducktape yet, can you please clarify how using DucktapeJSONEncoder helps with this:
? Overall I don't have a strong opinion yet, but don't see much harm in using our own load(s) and dump(s) methods. |
Fix #250