wikkid not compatible with zope.interface 4.0.1

Bug #1071936 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Wikkid Wiki
New
Undecided
Unassigned

Bug Description

The build of wikkid 0.1+bzr69 fails with zope.interface 4.0.1 (as will be the case in Ubuntu 13.04). The reason is that register_view() is making incorrect assumptions about whether the key is in _VIEW_REGISTRY or not, based on this bug in an earlier version of zope.interface: LP: #570942

======================================================================
ERROR: wikkid.tests.test_view_dispatcher.TestGetView.test_interface_view_registered_default
----------------------------------------------------------------------
Traceback (most recent call last):
  File "wikkid/tests/test_view_dispatcher.py", line 72, in test_interface_view_registered_default
    register_view(AView)
  File "wikkid/dispatcher.py", line 56, in register_view
    assert key not in _VIEW_REGISTRY, "key already registered: %r" % key
TypeError: not all arguments converted during string formatting
======================================================================
ERROR: wikkid.tests.test_view_dispatcher.TestViewRegistration.test_registration
----------------------------------------------------------------------
Traceback (most recent call last):
  File "wikkid/tests/test_view_dispatcher.py", line 88, in test_registration
    class AView(BaseView):
  File "wikkid/view/base.py", line 25, in __new__
    register_view(instance)
  File "wikkid/dispatcher.py", line 56, in register_view
    assert key not in _VIEW_REGISTRY, "key already registered: %r" % key
TypeError: Error when calling the metaclass bases
    not all arguments converted during string formatting

That actually masks the real problem, which is that the assertion is failing. So the immediate fix is to change the assert line to:

    assert key not in _VIEW_REGISTRY, "key already registered: %r" % (key,)

since key is a tuple. Of course, you'll just get a different failure in the same tests, and this is why:

when register_view() is called inside test_interface_view_registered_default() and test_registration(), stepping into register_view() will show you that _VIEW_REGISTRY already has a key in it of the (IHasInterface, 'name') tuple. However in the older zope.interface bug, the equality test triggered by the 'key not in _VIEW_REGISTRY' assertion will fail, so in fact, the test will *always* replace the _VIEW_REGISTRY key/value.

In the fixed z.i 4.0.1, the equality test properly passes, thus the assertion itself fails.

I believe the reason is that the tests pollute _VIEW_REGISTRY and don't clean up after themselves, but I'm not positive about this. For now, wikkid will be broken in Raring, but I'm happy to sponsor a fix if you have one.

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.