"AttributeError: plone" when writing fucntional doctests for Plone 3.0
Martin Aspeli
optilude at gmx.net
Tue Jun 19 19:02:29 UTC 2007
Derek Richardson wrote:
> I am getting an "AttributeError: plone" when attempting to write functional
> doctests for Plone 3.0:
>
>
> Error in test
> /Users/dkr/viceplone/lib/python/plone/syndication/tests/plone_functional.txt
> Traceback (most recent call last):
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/unittest.py",
> line 251, in run
> self.setUp()
> File "/usr/local/Zope-2.10.3/lib/python/zope/testing/doctest.py", line 2276,
> in setUp
> self._dt_setUp(test)
> File
> "/usr/local/Zope-2.10.3/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py",
> line 246, in setUp
> test_instance.setUp()
> File
> "/usr/local/Zope-2.10.3/lib/python/Testing/ZopeTestCase/PortalTestCase.py", line
> 60, in setUp
> self.portal = self._portal()
> File "/Users/dkr/viceplone/Products/PloneTestCase/PloneTestCase.py", line 61,
> in _portal
> portal = self.getPortal()
> File "/Users/dkr/viceplone/Products/PloneTestCase/PloneTestCase.py", line 80,
> in getPortal
> return getattr(self.app, portal_name)
> AttributeError: plone
>
>
> It looks like the initialization of the test is incomplete or is being
> interfered with, as the AttributeError seems to be because the PloneTestCase is
> looking for a "plone" attribute on the zope instance being created for the test
> and not finding it. Here is the (very simple) test case I've written:
>
>
> from Products.PloneTestCase import PloneTestCase
>
> PloneTestCase.setupPloneSite()
>
> class ViceTestCase(PloneTestCase.PloneTestCase):
> pass
> class ViceFunctionalTestCase(PloneTestCase.FunctionalTestCase):
> pass
>
>
> And, more to the point, here is the test runner:
>
>
> """Vice functional doctests.
> """
>
> import doctest
> import unittest
> import FunctionalDocFileSuite as Suite
You probably need the one from Zope's Testing.ZopeTestCase here...
> from plone.syndication.tests import vicetestcase
>
> OPTIONFLAGS = (doctest.REPORT_ONLY_FIRST_FAILURE |
> doctest.ELLIPSIS |
> doctest.NORMALIZE_WHITESPACE)
>
> def test_suite():
> return unittest.TestSuite(
> Suite("plone_functional.txt",
> optionflags=OPTIONFLAGS,
> package='plone.syndication.tests',
> test_class=vicetestcase.ViceFunctionalTestCase,
> )
> )
>
>
> I have been trying to emulate the functional doctests in PloneBoard
> (http://dev.plone.org/collective/browser/Ploneboard/trunk/tests).
If you're still stuck, email me in private and I can send you some
non-public code which I know to work. In return, please help me update
the testing tutorial on plone.org/documentation/tutorial/testing to make
sure it's correct. :)
Martin
--
Acquisition is a jealous mistress
More information about the Product-Developers
mailing list