Mocking Component.render_to_response #844
-
This might be my lack of Python knowledge here, but I'm struggling to mock the render_to_response method on Component. I want to be able to check that the correct context values are being passed to the method (hence wanting to mock it). However, it looks like it's doing some juggling to allow the method to both be a class method and an instance method depending on how its called
Am i missing something obvious? Is there a specific way you would go about mocking something like this in Python? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So far I always tested only the output HTML, not the context, so I haven't tried mocking Some options that come to mind:
|
Beta Was this translation helpful? Give feedback.
So far I always tested only the output HTML, not the context, so I haven't tried mocking
render_to_response
.Some options that come to mind:
self._render()
instead - this is the normalized entrypoint, and it doesn't get re-applied like the publicrender
andrender_to_response
doget_context_data()
, e.g.