[Zope-Coders] Importing Zope in tests

Tres Seaver tseaver@zope.com
Fri, 11 Jan 2002 12:45:18 -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?
> 
> What should we be doing instead?!

A unit text containing 'import Zope' is likely depending on
one of the many global side effects caused by that import.
Reliance on these side effects is ususally a Bad Thing (TM),
and signals that the test writer didn't build enough scaffolding,
choosing instead to let the framework do things.

One problem with having unit tests importing Zope is that
the side effects are hidden, non-revertable, and may cause
havoc on tests which run later (which would themselves be less
vulnerable if they didn't 'import Zope'!)

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com