[Twisted-Python] Unit testing AMP responder method registration
Hi! I'm trying to write code using TDD and AMP. I'm trying to figure out how to write a unit test for: @MyCommand.responder Specifically, I would assume that test: 1. Tests that the responder locator has a responder for MyCommand; 2. That responder matches the decorated method (1) is easy, (2) not so much. Since usually the responder locator gives me this nasty "doit" function that isn't introspectable (unless it.func_closure[0].cell_contents.im_func counts as "introspection"), I'm not sure how to write that unit test. I do have end-to-end tests for this, obviously: I would like to also have regular tests :) thanks in advance lvh
On 3 Dec, 01:19 pm, _@lvh.io wrote:
Hi!
I'm trying to write code using TDD and AMP. I'm trying to figure out how to write a unit test for:
@MyCommand.responder
Specifically, I would assume that test:
1. Tests that the responder locator has a responder for MyCommand; 2. That responder matches the decorated method
(1) is easy, (2) not so much. Since usually the responder locator gives me this nasty "doit" function that isn't introspectable (unless it.func_closure[0].cell_contents.im_func counts as "introspection"), I'm not sure how to write that unit test.
I do have end-to-end tests for this, obviously: I would like to also have regular tests :)
Here's what I've done: https://bazaar.launchpad.net/~game- hackers/game/trunk/view/head:/game/test/test_network.py#L418 Jean-Paul
On Wed, Dec 4, 2013 at 9:02 AM, <exarkun@twistedmatrix.com> wrote:
https://bazaar.launchpad.net/~game- hackers/game/trunk/view/head:/ game/test/test_network.py#L418
Thanks! I'll see how I can incorporate this. It does seem like the obvious test. Right now this is more spread out in my tests: I currently test the locator directly and the command separately. cheers lvh
participants (2)
-
exarkun@twistedmatrix.com -
Laurens Van Houtven