On 6/25/07, <b class="gmail_sendername">Brendon Colby</b> &lt;<a href="mailto:brendoncolby@gmail.com">brendoncolby@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 6/25/07, Christian Simms &lt;<a href="mailto:christian.simms@gmail.com">christian.simms@gmail.com</a>&gt; wrote:<br><br>[snip]<br>&gt; I think you have a race condition because (I assume) self.p.lineReceived<br>&gt; indirectly did a database insert, and then the 
self.check did a database<br>&gt; select.&nbsp;&nbsp;If that&#39;s true, you should make your test use Deferred&#39;s like this:<br><br>No - I&#39;m just doing a series of runQuerys() when the server starts,<br>the callbacks of which populate dictionaries with objects. The test
<br>sends a string identifier to the server which checks whether or not it<br>exists in one of these dictionaries. When the test runs, the dict is<br>empty. However, the load method IS running, just (seemingly) after the<br>
test is run. I guess I&#39;m not sure how to code a test for this, as in,<br>&quot;after the database connection has been made and the data loaded, THEN<br>start running tests.&quot;<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[snip]<br></blockquote></div><br><br>Looks like I mis-assumed your problem, sorry.&nbsp; In the setUp method in your tests, you should return a Deferred which fires when all your data is loaded.&nbsp; This can be a pain if you already organized your code into classes inheriting from 
twisted.application.service.Service which have startService/stopService calls. It&#39;s a pain because trial doesn&#39;t create an application object like running inside twistd does.&nbsp; So, in the case of writing unit tests for applications, you can abstract out your initialization code into a method, and then call that method directly in your setUp method.
<br><br>Cheers,<br>Christian<br>