[Zope-Coders] Importing Zope in tests

Shane Hathaway shane@zope.com
Fri, 11 Jan 2002 12:42:28 -0500


Chris Withers wrote:

> Shane Hathaway wrote:
> 
>>Log Message:
>>These changes make it so you can safely "import Zope" in a unit test.  You
>>still shouldn't import Zope in unit tests, 
> 
> Why not?


Importing Zope causes the whole product registry (with help files, etc.) 
to be built in a DemoStorage.  Some tests need a complete product 
registry.  But most don't.  If you import Zope, your unit tests will 
take a lot longer to run.

> What should we be doing instead?!


Import only the individual packages and modules you need.  For example, 
yesterday I changed a ParsedXML test so that instead of importing Zope, 
it just creates an OFS.Application and adds objects to it.  The test was 
only testing acquisition, but you don't need Zope or ZODB to use 
acquisition.

> Chris - fighting hard to make testing work, constantly confused :-S

I've expanded the nightly tests to include ZEO, bsddb3Storage, and CMF. 
  I tried to include ParsedXML as well but the current CVS has a *lot* 
of failed tests and a prominent crash bug.  But other than that, things 
are finally shaping up IMHO.

Shane