[Zope3-Users] zope.app.component.tests.test_site.py doctests failing
Sven Schomaker
Sven.Schomaker at linie-m.de
Tue Mar 8 08:57:10 EST 2005
Hello all,
I tried to get in to the revised site manager stuff but I didn't
manage to get it up running. I started out with a simple local
utility registration:
from persistent import Persistent
from zope.app import zapi
from zope.app.tests import setup
from zope.interface import Interface, implements
from zope.app.container.contained import Contained
from zope.app.component.site import LocalSiteManager
from zope.app.workflow.tests.workflowsetup import WorkflowSetup
from zope.app.component.site import UtilityRegistration
from zope.app.component.interfaces import ILocalUtility
from zope.app.component.interfaces.registration import ActiveStatus
class ITestUtility(Interface):
"""
Test utility interface.
"""
pass
class TestUtility(Contained, Persistent):
implements(ITestUtility, ILocalUtility)
wfs = WorkflowSetup()
wfs.setUp()
folder2_1 = zapi.traverse(
zapi.getRoot(wfs.sm),
"/folder2/folder2_1")
sm = LocalSiteManager(folder2_1)
folder2_1.setSiteManager(sm)
sm = folder2_1.getSiteManager()
sm_folder = sm['default']
sm_folder['test1.0'] = TestUtility()
rm = sm_folder.registrationManager
rg = UtilityRegistration('test1.0',
sm_folder['test1.0'], rm)
rm.addRegistration(rg)
rg.status = ActiveStatus
sm.queryUtility(ITestUtility, 'test1.0')
The retrieval of the utility from the sm fails
giving the following stacktrace.
File "/usr/local/lib/python2.4/site-packages/zope/component/site.py",
line 90, in queryUtility
byname = self.utilities._null.get(interface)
File
"/usr/local/lib/python2.4/site-packages/zope/interface/adapter.py", line
227, in get
self.clean()
File
"/usr/local/lib/python2.4/site-packages/zope/app/component/adapter.py",
line 49, in clean
super(LocalSurrogate, self).clean()
File
"/usr/local/lib/python2.4/site-packages/zope/interface/adapter.py", line
152, in clean
self.selfImplied, self.multImplied = adapterImplied(self.adapters)
File
"/usr/local/lib/python2.4/site-packages/zope/interface/adapter.py", line
655, in adapterImplied
_add_named_sub_adapter(target, implied, value)
File
"/usr/local/lib/python2.4/site-packages/zope/interface/adapter.py", line
720, in _add_named_sub_adapter
for b in target.__bases__:
AttributeError: 'TestUtility' object has no attribute '__bases__'
Since I didn't know any better I checked out the tests located
in zope.app.component and they also fail giving the following
output:
python2.3 test_site.py
.....F
======================================================================
FAIL: Doctest: site.txt
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py", line
2187, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for site.txt
File "../site.txt", line 0
----------------------------------------------------------------------
File "../site.txt", line 200, in site.txt
Failed example:
sys.modules['zope.app.component.tests'].FileSize = FileSize
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[60]>", line 1, in ?
sys.modules['zope.app.component.tests'].FileSize = FileSize
KeyError: 'zope.app.component.tests'
----------------------------------------------------------------------
File "../site.txt", line 214, in site.txt
Failed example:
size.__class__
Expected:
<class 'FileSize'>
Got:
<type 'NoneType'>
----------------------------------------------------------------------
File "../site.txt", line 216, in site.txt
Failed example:
size.context is file
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[67]>", line 1, in ?
size.context is file
AttributeError: 'NoneType' object has no attribute 'context'
----------------------------------------------------------------------
File "../site.txt", line 236, in site.txt
Failed example:
size = ISized(file)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[71]>", line 1, in ?
size = ISized(file)
File
"/usr/lib/python2.3/site-packages/zope/interface/interface.py", line698,
in __call__
raise TypeError("Could not adapt", obj, self)
TypeError: ('Could not adapt', <File object at 0x40a87f0c>,
<InterfaceClass__builtin__.ISized>)
----------------------------------------------------------------------
File "../site.txt", line 237, in site.txt
Failed example:
size.__class__
Expected:
<class 'FileSize'>
Got:
<type 'NoneType'>
----------------------------------------------------------------------
File "../site.txt", line 239, in site.txt
Failed example:
size.context is file
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[73]>", line 1, in ?
size.context is file
AttributeError: 'NoneType' object has no attribute 'context'
----------------------------------------------------------------------
File "../site.txt", line 346, in site.txt
Failed example:
sys.modules['zope.app.component.tests'].IMyUtility = IMyUtility
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[101]>", line 1, in ?
sys.modules['zope.app.component.tests'].IMyUtility = IMyUtility
KeyError: 'zope.app.component.tests'
----------------------------------------------------------------------
File "../site.txt", line 348, in site.txt
Failed example:
sys.modules['zope.app.component.tests'].MyUtility = MyUtility
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[103]>", line 1, in ?
sys.modules['zope.app.component.tests'].MyUtility = MyUtility
KeyError: 'zope.app.component.tests'
----------------------------------------------------------------------
File "../site.txt", line 352, in site.txt
Failed example:
myfolder['myfolder11'] = locationCopy(myfolder2['myfolder21'])
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[106]>", line 1, in ?
myfolder['myfolder11'] = locationCopy(myfolder2['myfolder21'])
File
"/usr/lib/python2.3/site-packages/zope/app/location/pickling.py", line
76, in locationCopy
pickler.dump(loc)
PicklingError: Can't pickle <InterfaceClass
zope.app.component.tests.IMyUtility>: attribute lookup
zope.app.component.tests.IMyUtility failed
----------------------------------------------------------------------
File "../site.txt", line 354, in site.txt
Failed example:
myfolder11 = myfolder['myfolder11']
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[107]>", line 1, in ?
myfolder11 = myfolder['myfolder11']
File "/usr/lib/python2.3/site-packages/zope/app/folder/folder.py",
line 64, in __getitem__
return self.data[name]
KeyError: 'myfolder11'
----------------------------------------------------------------------
File "../site.txt", line 355, in site.txt
Failed example:
myfolder11.getSiteManager().next is myfolder.getSiteManager()
Expected:
True
Got:
False
----------------------------------------------------------------------
File "../site.txt", line 357, in site.txt
Failed example:
myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/zope/testing/doctest.py",
line 1256, in __run
compileflags, 1) in test.globs
File "<doctest site.txt[109]>", line 1, in ?
myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
IndexError: tuple index out of range
----------------------------------------------------------------------
Ran 6 tests in 0.394s
FAILED (failures=1)
Is this a failure on my side or is there a problem with the trunk?
Checked out revision 29417 today. Compiled the z3 sources and executed the
test with Python 2.3.4 [GCC 3.3.4 (pre 3.3.5 20040809)].
Any Ideas?
More information about the Zope3-users
mailing list