July 6, 2007
6:26 p.m.
On Fri, 6 Jul 2007 10:47:16 -0700, Mike Klaas <mike.klaas@gmail.com> wrote:
On 6-Jul-07, at 6:45 AM, Yaakov Nemoy wrote:
I can do the other three parts, but I am wondering, how do I write a deterministic test unit for my patch? How is it done with the threading model in python in general?
I don't know how it is done in general, but for reference, here are some of the unittests for my read/write lock class:
[snip]
read.release() self.assertEqual(wrlock.readerCount, 0) time.sleep(.1) self.assertTrue(writer.gotit)
Not exactly deterministic. Instead of a flag attribute, try using an Event or a Condition. Either of these will let you know exactly when the necessary operation has completed. Jean-Paul