[Zope-CMF] unit test weirdness.
20 Feb 2003 08:27:35 -0500
On Thu, 2003-02-20 at 08:03, Mark McEahern wrote:
> [Chris Withers]
> > That's because neither of those is the canonical way of running
> > CMF unit tests.
> > They should be run using:
> > python all_cmf_tests.py [-q]
> > ...from your Products directory.
> Hmm, all_cmf_tests.py does a plain import of Zope, assuming it is already
> started. That works, I guess, if you're running ZEO. I'm not. So here's
> what I'm seeing (appended to the end below).
> Q: Is this a bug in CMF?
The "Zope.startup()" dance is a *very* recent requirement for Zope,
introduced only after 2.6.0; prior to that, "import Zope" was the only
way for product unit tests outside of the SOFTWARE_HOME to ensure that
their product was stitched into the 'Products' package.
Any fix needs to be "forward-compatible" (e.g., the tests must still run
on Zope 2.5). E.g.:
except NameError: # pre Zope 2.6.1
> I think it is, but perhaps I don't understand the
> design philosophy behind Zope unit tests. I've always assumed each unit
> test should be isolated, capable of being run by itself without a lot of
> rigamarole. The notion that there's a "canonical" way to run the tests
> (forcing you to run them in a big suite) seems contrary to that. I would
> think the canonical way to run any unit test would be:
> python testname.py
Running individual unit tests as scripts is *not* the canonical way to
run in a Zope setup; getting the dependencies right for all the Zope
machinery is too much to expect individual test writers to do, and to
> where testname.py is a single module with one or more TestCase instances in
> it. That's not contrary to having a way to run them all at once--but your
> statement about canonical suggests a design philosophy that makes a false
> dichotomy between running one test and running them all.
> Of course, what's likely is that there's something I just don't understand.
> Please help me.
Running with 'all_unit_tests' *is* canonical for the CMF, as Chris
suggests. Given the need to do the setup, the actual incremental cost
is not that much higher anyway. :)
Tres Seaver firstname.lastname@example.org
Zope Corporation "Zope Dealers" http://www.zope.com