[mochikit] MochiKit.Async, synchronousness, and testing

2007-06-11 Thread GK

I've been Googling around looking for tools to help with testing of
asynchronous code using mochikit's Deferred's.  The only thing I found
so far was this post from over a year ago, to which there was no
response.
  http://groups.google.com/group/mochikit/msg/53af9c5dece6e576

What I'm looking for is something akin to the 'twisted.trial.unittest'
package that extends a synchronous unit test framework to handle
deferred results.  Ideally, I'd like to be able to mix synchronous and
deferred tests in a single suite.

I think I can see a way to achieve this, effectively absorbing all the
tests into a reactor monad (wrapping any synchronous values in
mochikit.async.succeed) and supplying a testrunner that collects the
results and analyzes them when all deferreds have fired.  But before I
spend too much effort trying to figure the details of doing this, I'd
be interested to hear if anyone has already done anything similar for
mochikit.

#g


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: MochiKit.Async, synchronousness, and testing

2007-06-11 Thread Bob Ippolito

On 6/11/07, GK [EMAIL PROTECTED] wrote:

 I've been Googling around looking for tools to help with testing of
 asynchronous code using mochikit's Deferred's.  The only thing I found
 so far was this post from over a year ago, to which there was no
 response.
   http://groups.google.com/group/mochikit/msg/53af9c5dece6e576

 What I'm looking for is something akin to the 'twisted.trial.unittest'
 package that extends a synchronous unit test framework to handle
 deferred results.  Ideally, I'd like to be able to mix synchronous and
 deferred tests in a single suite.

 I think I can see a way to achieve this, effectively absorbing all the
 tests into a reactor monad (wrapping any synchronous values in
 mochikit.async.succeed) and supplying a testrunner that collects the
 results and analyzes them when all deferreds have fired.  But before I
 spend too much effort trying to figure the details of doing this, I'd
 be interested to hear if anyone has already done anything similar for
 mochikit.


How about looking at how MochiKit.Async's tests work?

-bob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: MochiKit.Async, synchronousness, and testing

2007-06-11 Thread GK

On Jun 11, 2:51 pm, Bob Ippolito [EMAIL PROTECTED] wrote:
 On 6/11/07, GK [EMAIL PROTECTED] wrote:





  I've been Googling around looking for tools to help with testing of
  asynchronous code using mochikit's Deferred's.  The only thing I found
  so far was this post from over a year ago, to which there was no
  response.
   http://groups.google.com/group/mochikit/msg/53af9c5dece6e576

  What I'm looking for is something akin to the 'twisted.trial.unittest'
  package that extends a synchronous unit test framework to handle
  deferred results.  Ideally, I'd like to be able to mix synchronous and
  deferred tests in a single suite.

  I think I can see a way to achieve this, effectively absorbing all the
  tests into a reactor monad (wrapping any synchronous values in
  mochikit.async.succeed) and supplying a testrunner that collects the
  results and analyzes them when all deferreds have fired.  But before I
  spend too much effort trying to figure the details of doing this, I'd
  be interested to hear if anyone has already done anything similar for
  mochikit.

 How about looking at how MochiKit.Async's tests work?

Ah, thanks!

I did previously take a look at tests/test_MochiKit-Async.html
(V1.3.1), but I think I missed the point.  Looking again, I think I am
getting the idea...

Your SimpleTest module accummulates a list of test results, then
displays the result, right? And test_MochiKit-Async uses a combination
of synchronous and asynchronous calls to add test results to this
list.  Plus waitForExplicitFinish() and finish() to hold off
completion until the Deferreds have fired.

This does seem simpler than my first thought.  But this module has
only one truly asynchronous callback that I can see:  so if there are
several asynchronous calls, some mechanism is needed to hold off
completion untill all are done.  (It occurred to me that adding a
sequence of callbacks to a single initially-empty Deferred, the last
of which invokes finish() might be a way to achieve this -- as I
recall, the callback-chaining logic effectively sequences callbacks
when a deferred is returned?)

I started out using JSunit rather than a Test.Simple like API, and I'd
like to be able to use by existing synchronous test suites unchanged.
But that, I think is just a matter of shimming a few calls.

Thanks for your prompt - there are ideas here I can use.

#g


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---