-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Extend HTTPretty.decorators #234
base: main
Are you sure you want to change the base?
Conversation
254444d
to
3f1e372
Compare
Linked httpretty.register with httpretty.activate_uri for convinience.
Updated docs.Still, I have to check the code examples and current functional/unit tests. I hope the tests aren't as shallow as the tests provided in the docs. They don't test all args provided to Linked
|
Ok, I think this is ready for review. |
assert response.text == "Find the best daily deals" | ||
response = requests.get("http://yipit.com/about/") | ||
assert response.text == "About us" | ||
response = requests..get("https://github.com/gabrielfalcao/HTTPretty") |
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.
request..get
? (extra dot)
You provide examples for most of how httpretty works; but not the callback methodology. Would you please add an example of that too? |
@BenjamenMeyer Since it's been a long time, I don't exactly remember any callback scenarios. Can you elaborate on what examples should I provide? Sorry for the troubles and thanks for the review! P.S the docs typo is fixed, but I want to have it in one commit with the examples you requested. |
@syndbg See https://github.com/gabrielfalcao/HTTPretty#dynamic-responses-through-callbacks Should be pretty simple as the function becomes the body parameter. |
Motivation:
Mainly Django decorators being DRY and making it really easy to see that X, Y, Z function/class/method will have a modified behavior.
In our case that's a mocked socket. So why not be able to use
register_uri
as a decorator?Writing
register_uri
in the body isn't the most pythonic approach.The change:
Instead of
We can now do this:
Also decorating classes is supported.
TODO:
register_uri kwargs
again through the newregister
decorator or a newregisters
decorator?Are you other users ok with this change? It's open to changes and it's definitely not final.
What do you think @gabrielfalcao ?
P.S this is rebased with #232