So I was going to work on some issues in listen. First thing I did was run the listen tests in a fresh opencore build:

$ zopectl test -s Products.listen
...
Total: 60 tests, 0 failures, 0 errors

So far so good. I made a few edits to explore the issues and ran again.

$ zopectl test -s Products.listen
...
Set up Products.PloneTestCase.layer.PloneSite
Traceback (most recent call last):
  File "/home/pw/opencore-pristine/opencore/src/Zope-2.9-branch/bin/test.py", line 125, in ?
    sys.exit(testrunner.run(defaults))
  File "/home/pw/opencore-pristine/opencore/src/Zope-2.9-branch/lib/python/zope/testing/testrunner.py", line 271, in run
    failed = not run_with_options(options)
  File "/home/pw/opencore-pristine/opencore/src/Zope-2.9-branch/lib/python/zope/testing/testrunner.py", line 433, in run_with_options
    setup_layers, failures, errors)
  File "/home/pw/opencore-pristine/opencore/src/Zope-2.9-branch/lib/python/zope/testing/testrunner.py", line 604, in run_layer
    setup_layer(layer, setup_layers)
  File "/home/pw/opencore-pristine/opencore/src/Zope-2.9-branch/lib/python/zope/testing/testrunner.py", line 692, in setup_layer
    layer.setUp()
  File "/home/pw/opencore-pristine/opencore/zope/Products/PloneTestCase/layer.py", line 28, in setUp
    setup.deferredSetup()
  File "/home/pw/opencore-pristine/opencore/zope/Products/PloneTestCase/setup.py", line 315, in deferredSetup
    SiteSetup(*site).run()
  File "/home/pw/opencore-pristine/opencore/zope/Products/PloneTestCase/setup.py", line 162, in run
    self._setupRegistries()
  File "/home/pw/opencore-pristine/opencore/zope/Products/PloneTestCase/setup.py", line 216, in _setupRegistries
    portal = getattr(self.app, self.id)
AttributeError: plone

Whoops, I broke something in my edits. Right?

Well, no. After much tearing of hair, I noticed that I could reliably do this in a totally fresh build:

  1. Run the listen tests. All pass.
  2. Run the listen tests again. Kaboom! AttributeError: plone

After tearing some hair, I discovered in the debugger that somehow, PloneTestCase.setup is broken on the second run. The plone site is created, transaction.commit() is called, at which point the newly comitted site vanishes in a puff of smoke.

WTF.


After yet more tearing of hair, I discovered that I could make the tests run again by doing:

find src/Zope-2.9-branch/lib/python -name “*pyc” -exec rm -f {} \;

And of course, the tests only work for one run after that. On the next run, kaboom. Until I remove the bytecode files again.

WTF.

After playing human-binary-search for a while, I narrowed it down to a single file which has no obvious relationship to anything persistent. Apparently I can do this reliably:

$ zopectl test -s Products.listen
...
AttributeError: plone
$ rm -f Zope-2.9-branch/lib/python/zope/app/form/browser/itemswidgets.pyc
$ zopectl test -s Products.listen
...
Total: 60 tests, 0 failures, 0 errors
$ zopectl test -s Products.listen
...
AttributeError: plone
$ rm -f Zope-2.9-branch/lib/python/zope/app/form/browser/itemswidgets.pyc
$ zopectl test -s Products.listen
...
Total: 60 tests, 0 failures, 0 errors


Weird, right?

I wondered if it was an issue with something imported by itemswidgets.py. There aren’t many imports in there, and after removing bytecode for all of them, I gradually narrowed it down to one import: xml.sax in the standard library. I shit you not. There is no way I can think of that xml.sax could impact PloneTestCase’s demostorage setup. But it does:

$ zopectl test -s Products.listen
...
AttributeError: plone
$ rm -f /usr/lib/python/xml/sax/*py[oc]
$ zopectl test -s Products.listen
...
Total: 60 tests, 0 failures, 0 errors

Of course, Rob Miller tried to reproduce and he never sees this error at all.

W T F

Filed November 29th, 2007 under Uncategorized
  1. Paul,
    rmarianski and I have been struggling with this guy for months. Congrats on making so much progress. I would always get it on my machine and rmarianski would never get it on his. I wouldn’t get the error if I ran the subpackages separately, only when I ran the whole listen suite.
    Chris

    Comment by cabraham on November 29, 2007 at 1:51 pm

  2. Hmm. What systems are you running on?
    I’m running gentoo on x86_64. I updated everything on the system a couple days ago.

    Comment by slinkp on November 29, 2007 at 2:09 pm

  3. we’re both running on Macs and right now I don’t have a problem running the tests anymore. Do you?

    Comment by cabraham on June 3, 2008 at 9:46 am

  4. Great story!

    Comment by suresh on June 25, 2008 at 1:26 am

Leave a comment