zope.testing gives UnboundLocalError on nfail

Bug #407916 reported by Martin Aspeli
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 3
Fix Released
Undecided
Unassigned
collective.buildout
Fix Released
Undecided
Unassigned
zope.testing
Fix Released
Undecided
Unassigned

Bug Description

I'm running the plone.z3cform tests in a Zope 2.10 instance with
zope.testing 3.8 installed.

All other tests seem to work OK, but with plone.z3cform's tests, I get:

$ ./bin/instance test -s plone.z3cform
Running tests at level 1
Running plone.z3cform.testing_zcml_layer tests:
   Set up plone.z3cform.testing_zcml_layer in 0.972 seconds.
   Running:
..........................
   Ran 26 tests with 0 failures and 0 errors in 0.219 seconds.
Running zope.testing.testrunner.layer.UnitTests tests:
   Tear down plone.z3cform.testing_zcml_layer ... not supported
Exception in thread Thread-1:
Traceback (most recent call last):
   File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/threading.py",
line 442, in __bootstrap
     self.run()
   File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/threading.py",
line 422, in run
     self.__target(*self.__args, **self.__kwargs)
   File
"/Users/optilude/.buildout/eggs/zope.testing-3.8.0-py2.4.egg/zope/testing/testrunner/runner.py",
line 418, in spawn_layer_in_subprocess
     while nfail > 0:
UnboundLocalError: local variable 'nfail' referenced before assignment

Total: 26 tests, 0 failures, 0 errors in 5.626 seconds.

The tests are here:
http://svn.zope.org/repos/main/plone.z3cform/trunk/plone/z3cform/tests.py

Revision history for this message
Godefroid Chapelle (gotcha) wrote :

That bug is supposedly fixed by

http://mail.zope.org/pipermail/checkins/2009-July/036586.html

It is triggered by other bug :
The test runner is trying to spawn a subprocess with the --resume-layer
argument. However, the --resume-layer argument is not accepted by the
subprocess.

This produces an error in a format not foreseen by the error parser.
(which then triggered the UnboundLocalError).

Revision history for this message
Marius Gedminas (mgedmin) wrote :

The fix hides the error, but the underlying bug appears to be still there. Note the total: 26 tests --- those are functional tests. There are also 40 unit tests that should be run but aren't.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

The test runner assumes it can re-start itself by running

  subprocess.Popen([sys.executable, sys.argv[0], ...])

Unfortunately this calls plone.z3cform/bin/instance without the 'test' argument.

I think this may need some coordinated fixing in collective.recipe.z2testrunner as well as in zope.testing.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Actually, it's plone.recipe.zope2instance that might need fixing, not collective.recipe.z2testrunner.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Solution:

  * zope.testing needs to get a new argument, --subprocess-extra-arg, that would be inserted between sys.argv[0] and the rest of the command line when zope.testing.testrunner wants to execute a subprocess

  * plone.recipe.zope2instance needs to be modified to add ['--subprocess-extra-arg', 'test'] to the arguments passed to zope.testing.testrunner.run()

Does anyone have a better idea?

FWIW I don't have commit access to svn.plone.org.

Revision history for this message
Godefroid Chapelle (gotcha) wrote :

I fixed this by allowing the clients of testrunner to provide a sequence of script parts.

This enables the runner to restart the script with the right invocation.

new versions of zope.testing and plone.recipe.zope2instance have been released.

It seems I cannot close this bug.

Changed in zope3:
status: New → Fix Released
Changed in collective.buildout:
status: New → Fix Released
Changed in zope.testing:
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.