-
Notifications
You must be signed in to change notification settings - Fork 96
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 property based test. #63
Conversation
JSON doesn't actually allow these (despite the json module in Python happily serializing / parsing 'nan'), and they make assertEqual fail since they're not equal to anything, including themselves.
1 similar comment
Thanks for your work! Let me address the issues that you raised:
I agree that rfc6901 does not mention anything about urlencoding, so >>> import jsonpointer
>>> obj = {'a b': 1}
>>> jsonpointer.resolve_pointer(obj, '/a b')
1 Could you please open an issue in stefankeogl/pyhon-json-pointer to describe the issue with an example (or isolated, failing test)? |
OK, I think I understand your point... rather than the example above, the failing example should be >>> import jsonpointer
>>> obj = {'a b': 1}
>>> jsonpointer.resolve_pointer(obj, '/a%20b')
1 Instead this should give an error because there is no member It seems that I added the unquoting (currently line 145) already in the very first commit. Initially the [RFC draft|https://tools.ietf.org/html/draft-pbryan-zyp-json-pointer-00] did contain
but this was removed before the final RFC, and is thus no longer correct. Would you be interested in submitting a pull request for |
Yup, your example is correct. I'll try to send a PR to |
I have now added an issue at stefankoegl/python-json-pointer#22. |
@mithrandi, do you still intend to work on this pull request? The tests are failing for most python versions, but the general idea seems interesting. |
I will continue the work in #79. |
Sorry, guess I never got back to this! Thanks for picking it up. |
Superseded by #79 I guess. |
This PR adds a property-based test using Hypothesis, that tests that a patch from a randomly generated source value to a randomly generated destination value is valid (yields the destination value when applied to the source value). This would have been able to find the bug in #55, among other things.
The test is currently failing due to an issue with jsonpointer that I'm not entirely sure how to fix. The first problem is that jsonpointer expects pointers to be urlencoded, which I don't think is correct (my reading of the RFC is that urlencoding should only be used when the pointer is part of a URL, so nothing special to JSON pointer itself). The second issue is that
JsonPointer.from_parts([u'%00'])
ends up generating a pointer of/\u0000
due to the parts being urldecoded; this is tangled up with the first issue.I'm happy to do the work to resolve these issues, but I'm not entirely sure what direction to go in, so would appreciate some guidance here. I think the correct thing for jsonpointer to do is to not do any url encoding/decoding at all, but of course this represents a fairly large change in the API.