ZopeTestCase and Zope.Startup() interactions

Bug #143418 reported by Lennart Regebro
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Unassigned

Bug Description

Stefan Holek and I have discovered some tricky interactions of ZopeTestCase tests and tests using Zope.Startup().

1. If you first run a test that uses Zope.Startup() and later run a test using ZopeTestCases installProduct() the product will get installed twice, first by Zope.Startup() and then by installProduct. This is not only a waste of processing time, it also causes test failures if the product you install uses CMFStetup. This is probably why this bug hasn't appeared before, CMFSetup is pretty new.

A fix for this exists in svn+ssh://<email address hidden>/repos/main/Zope/branches/regebro-product_installation_tracking and will be merged into trunk and 2.8 soon (like today or tomorrow).

2. If you first run a test using ZopeTestCase, and then run a test using Zope.Startup() Zope.Startup() will not install any products. I haven't tested this (it's according to Stefan Holek). This will happen for example if you have Archetypes installed and run all tests in Products, with "bin/zopectl test" or similar.

I don't have a solution for this yet.

Tags: bug zope
Revision history for this message
Stefan H. Holek (stefanholek) wrote :

"Discovered some tricky interactions" is not entirely correct. I knew about this all along ;-)

One of the very reasons of ZTC's existence is that Zope.startup() was perceived to suck for testing. This is why there is a ZopeLite module in the first place. Zope.startup() pulls in *all* products which may be fine for testing the Zope core, but is not desirable when testing add-on products. That's because

  a) It is unbearably slow.
  b) You never really know what is actually installed.

So, mixing ZTC and non-ZTC tests in a single run was never in the cards, and I don't consider this a "bug" either.

Let's see what we can do once Lennart has landed his branch...

Revision history for this message
Stefan H. Holek (stefanholek) wrote :

Ok, so now that I've actually looked at the branch <wink> I think it is unnecessary in its current form. ZTC can detect whether Zope.startup() has been run just fine (by checking Zope._began_startup), and turn ZopeLite.installProduct() into a noop. I think that's the intention here, anyway.

Revision history for this message
Lennart Regebro (regebro-gmail) wrote :

OK, I'll check into that tomorrow, that could work too.

Revision history for this message
Lennart Regebro (regebro-gmail) wrote :

OK, I checked in a version that does what you suggested. It has the benefit of needing no changes to Zope.OFS.Application, but on the other hand it makes ZopeTestCase uglier. Prettify if you like.

I also tried to make tests for this, but failed. ;) You can ignore them.

Revision history for this message
Hanno Schlichting (hannosch) wrote :

Reading the comments, it sounds like all issues have been addressed here.

Changed in zope2:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.