[Zope] unittest a component that is using zope.dublincore

Jean-Michel FRANCOIS jeanmichel.francois at makina-corpus.com
Sat Mar 28 10:46:56 EDT 2009


Hi,
  I m trying to make my first content type with zope3. The code is
available there: http://github.com/toutpt/z3weblog.entry/tree

I m following the second edition of the book "web component developement
with zope3", i know this is not the last edition. So, i m making a
ISized component for my simple content type, with a simple unittest, but
now, i want to use zope.dublincore package and i get an error when i m
launch the tests:

=================
(zope3apps)toutpt at linux-tggd:~/workspace/zope3apps/apps/prout> .bin/test
Running tests at level 1
Running unit tests:
  Running:
...

Error in test test_size_for_display
(z3weblog.entry.tests.test_size.EntrySizeTestCase)
Traceback (most recent call last):
  File
"/home/toutpt/outils/python_system/2.5.4/lib/python2.5/unittest.py",
line 260, in run
    testMethod()
  File
"/home/toutpt/workspace/zope3apps/apps/prout/src/z3weblog.entry/src/z3weblog/entry/tests/test_size.py",
line 21, in test_size_for_display
    msg = self.size.sizeForDisplay()
  File
"/home/toutpt/workspace/zope3apps/apps/prout/src/z3weblog.entry/src/z3weblog/entry/size.py",
line 24, in sizeForDisplay
    unit, chars = self.sizeForSorting()
  File
"/home/toutpt/workspace/zope3apps/apps/prout/src/z3weblog.entry/src/z3weblog/entry/size.py",
line 18, in sizeForSorting
    dc = dcI.IZopeDublinCore(self.context)
TypeError: ('Could not adapt', <z3weblog.entry.content.ZODBWeblogEntry
object at 0x839382c>, <InterfaceClass
zope.dublincore.interfaces.IZopeDublinCore>)

.

Error in test test_size_for_sorting
(z3weblog.entry.tests.test_size.EntrySizeTestCase)
Traceback (most recent call last):
  File
"/home/toutpt/outils/python_system/2.5.4/lib/python2.5/unittest.py",
line 260, in run
    testMethod()
  File
"/home/toutpt/workspace/zope3apps/apps/prout/src/z3weblog.entry/src/z3weblog/entry/tests/test_size.py",
line 16, in test_size_for_sorting
    unit, size = self.size.sizeForSorting()
  File
"/home/toutpt/workspace/zope3apps/apps/prout/src/z3weblog.entry/src/z3weblog/entry/size.py",
line 18, in sizeForSorting
    dc = dcI.IZopeDublinCore(self.context)
TypeError: ('Could not adapt', <z3weblog.entry.content.ZODBWeblogEntry
object at 0x839382c>, <InterfaceClass
zope.dublincore.interfaces.IZopeDublinCore>)


  Ran 4 tests with 0 failures and 2 errors in 0.007 seconds.

Tests with errors:
   test_size_for_display (z3weblog.entry.tests.test_size.EntrySizeTestCase)
   test_size_for_sorting (z3weblog.entry.tests.test_size.EntrySizeTestCase)

============

The trace back is very clear, the zope.dublincore components are not
loaded. The question is : what is the best way to load components in
unittests ? Do just i have to load the zcml of zope.dublincore, or do i
have to register only needed components, if so how can i do that ?

JeanMichel FRANCOIS
Makina-Corpus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jeanmichel_francois.vcf
Type: text/x-vcard
Size: 374 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20090328/33fa9c4d/attachment.vcf 


More information about the Zope mailing list