[Product-Developers] bug on PloneTestCase?

Héctor Velarde hector.velarde at gmail.com
Thu Feb 3 16:30:46 UTC 2011


hi there!

I'm writing a test to verify a content type and I'm getting the 
following UnicodeDecodeError when running bin/test:

Error in test testCreateArticle 
(upn.content.tests.test_publications.TestArticle)
Traceback (most recent call last):
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Testing/ZopeTestCase/profiler.py", 
line 86, in __call__
     self.setUp()
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Testing/ZopeTestCase/PortalTestCase.py", 
line 62, in setUp
     self.afterSetUp()
   File 
"/usr/local/Plone/upn/src/upn.content/upn/content/tests/test_publications.py", 
line 23, in afterSetUp
     self.publications.invokeFactory('CVArticle', 'article')
   File 
"/usr/local/Plone/upn/eggs/Products.ATContentTypes-1.3.4-py2.4.egg/Products/ATContentTypes/lib/constraintypes.py", 
line 281, in invokeFactory
     RESPONSE=None, *args, **kw)
   File 
"/usr/local/Plone/upn/eggs/Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/PortalFolder.py", 
line 315, in invokeFactory
     return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
   File 
"/usr/local/Plone/upn/eggs/Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/TypesTool.py", 
line 716, in constructContent
     ob = info.constructInstance(container, id, *args, **kw)
   File 
"/usr/local/Plone/upn/eggs/Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/TypesTool.py", 
line 276, in constructInstance
     ob = self._constructInstance(container, id, *args, **kw)
   File 
"/usr/local/Plone/upn/eggs/Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/TypesTool.py", 
line 450, in _constructInstance
     newid = m(id, *args, **kw)
   File "<string>", line 7, in addCVArticle
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/OFS/ObjectManager.py", line 
348, in _setObject
     notify(ObjectAddedEvent(ob, self, id))
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/event/__init__.py", 
line 23, in notify
     subscriber(event)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/event.py", 
line 26, in dispatch
     for ignored in zope.component.subscribers(event, None):
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/_api.py", 
line 130, in subscribers
     return sitemanager.subscribers(objects, interface)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/registry.py", line 
290, in subscribers
     return self.adapters.subscribers(objects, provided)
   File 
"/usr/local/Plone/upn/eggs/zope.interface-3.5.3-py2.4-linux-x86_64.egg/zope/interface/adapter.py", 
line 575, in subscribers
     subscription(*objects)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/event.py", 
line 33, in objectEventNotify
     adapters = zope.component.subscribers((event.object, event), None)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/_api.py", 
line 130, in subscribers
     return sitemanager.subscribers(objects, interface)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/zope/component/registry.py", line 
290, in subscribers
     return self.adapters.subscribers(objects, provided)
   File 
"/usr/local/Plone/upn/eggs/zope.interface-3.5.3-py2.4-linux-x86_64.egg/zope/interface/adapter.py", 
line 575, in subscribers
     subscription(*objects)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/OFS/subscribers.py", line 
116, in dispatchObjectMovedEvent
     callManageAfterAdd(ob, event.object, event.newParent)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/OFS/subscribers.py", line 
149, in callManageAfterAdd
     ob.manage_afterAdd(item, container)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/BaseContent.py", 
line 39, in manage_afterAdd
     BaseObject.manage_afterAdd(self, item, container)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/BaseObject.py", 
line 162, in manage_afterAdd
     Referenceable.manage_afterAdd(self, item, container)
    - __traceback_info__: (<ImplicitAcquirerWrapper object at 
0x6f4c990>, <ImplicitAcquirerWrapper object at 0x6f4c990>, 
<ImplicitAcquirerWrapper object at 0x6f43b10>)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/Referenceable.py", 
line 227, in manage_afterAdd
     self._updateCatalog(container)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/Referenceable.py", 
line 200, in _updateCatalog
     self._catalogUID(container, uc=uc)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/Referenceable.py", 
line 302, in _catalogUID
     uc.catalog_object(self, url)
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/UIDCatalog.py", 
line 212, in catalog_object
     update_metadata, pghandler=pghandler)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Products/ZCatalog/ZCatalog.py", 
line 536, in catalog_object
     update_metadata=update_metadata)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Products/ZCatalog/Catalog.py", 
line 340, in catalogObject
     index = self.updateMetadata(object, uid)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Products/ZCatalog/Catalog.py", 
line 278, in updateMetadata
     newDataRecord = self.recordify(object)
   File 
"/usr/local/Plone/upn/parts/zope2/lib/python/Products/ZCatalog/Catalog.py", 
line 418, in recordify
     if(attr is not MV and safe_callable(attr)): attr=attr()
   File 
"/usr/local/Plone/upn/eggs/Products.Archetypes-1.5.15-py2.4.egg/Products/Archetypes/BaseObject.py", 
line 234, in Type
     return ti.Title()
   File 
"/usr/local/Plone/upn/eggs/Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/TypesTool.py", 
line 191, in Title
     return Message(self.title, self.i18n_domain)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-5: 
invalid data

the error is only displayed when using bin/test; no error is shown when 
adding the content type TTW or running bin/roadrunner.

the cause of the error is the use of extended characters inside the XML 
file that defines the content type (<property name="title"> and/or 
<property name="description">):

<?xml version="1.0"?>
<object name="CVArticle"
    meta_type="Factory-based Type Information with dynamic views"
    i18n:domain="upn.content" 
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
   <property name="title" i18n:translate="">Artículo</property>
   <property name="description"
     i18n:translate="">Publicación de artículo</property>
   [...]
</object>

if I remove the extended characters, the test passes.

is this a bug on PloneTestCase?
-- 
Héctor Velarde


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5620 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110203/844ebd9d/attachment.p7s>


More information about the Product-Developers mailing list