Hi all,

I'm doing some doctests wih plone.app.testing and finally reached an error
that I don't quite understand:

Traceback caused on doctest:

---------------------------------------------------->8-----------------------------------------------------
Failed example:
    browser.open(portal_url + '/login_form')
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[12]>", line 1, in <module>
        browser.open(portal_url + '/login_form')
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/zope.testbrowser-3.11.1-py2.7.egg/zope/testbrowser/browser.py",
line 240, in open
        self.mech_browser.open(url, data)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/mechanize-0.2.5-py2.7.egg/mechanize/_mechanize.py",
line 203, in open
        return self._mech_open(url, data, timeout=timeout)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/mechanize-0.2.5-py2.7.egg/mechanize/_mechanize.py",
line 230, in _mech_open
        response = UserAgentBase.open(self, request, data)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/mechanize-0.2.5-py2.7.egg/mechanize/_opener.py",
line 193, in open
        response = urlopen(self, req, data)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/mechanize-0.2.5-py2.7.egg/mechanize/_urllib2_fork.py",
line 344, in _open
        '_open', req)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/mechanize-0.2.5-py2.7.egg/mechanize/_urllib2_fork.py",
line 332, in _call_chain
        result = func(*args)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/Zope2-2.13.6-py2.7.egg/Testing/testbrowser.py",
line 83, in http_open
        return self.do_open(PublisherConnection, req)
      File "/usr/lib/python2.7/urllib2.py", line 1154, in do_open
        h.request(req.get_method(), req.get_selector(), req.data, headers)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/zope.testbrowser-3.11.1-py2.7.egg/zope/testbrowser/testing.py",
line 76, in request
        self.response = self.caller(request_string, handle_errors)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/Zope2-2.13.6-py2.7.egg/Testing/ZopeTestCase/functional.py",
line 38, in wrapped_func
        return func(*args, **kw)
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/Zope2-2.13.6-py2.7.egg/Testing/ZopeTestCase/zopedoctest/functional.py",
line 193, in http
        sync()
      File
"/home/tzicatl/Aplicaciones/Buildout/egss/Zope2-2.13.6-py2.7.egg/Testing/ZopeTestCase/zopedoctest/functional.py",
line 115, in sync
        getRootFolder()._p_jar.sync()
    AttributeError: 'NoneType' object has no attribute '_p_jar'

---------------------------------------------------->8-----------------------------------------------------

My test are arranged in two files inside a 'test' package. The file base.py
contains this.

---------------------------------------------------->8-----------------------------------------------------

from plone.app.testing import quickInstallProduct
from plone.app.testing import IntegrationTesting, FunctionalTesting
from plone.app.testing import PloneSandboxLayer


class MyFixture(PloneSandboxLayer):
    def setUpPloneSite(self, portal):
        quickInstallProduct(portal,'my.package')

LW_FIXTURE = MyFixture()
# FunctionalTesting will create a stacked DemoStorage for each test and pop
it on test tear- down
LW_FUNCTIONAL_TESTING = FunctionalTesting(bases=(LW_FIXTURE,),
name="MyFixture:Functional")

---------------------------------------------------->8-----------------------------------------------------

And ther's also a test_doctests.py

---------------------------------------------------->8-----------------------------------------------------
import unittest
import doctest
from plone.testing import layered
from libroweb.coretypes.tests import base


def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        layered(doctest.DocFileSuite('README.txt', package='my.package',

 optionflags=doctest.REPORT_ONLY_FIRST_FAILURE |
                                     doctest.NORMALIZE_WHITESPACE |
doctest.ELLIPSIS),
                layer=base.LW_FUNCTIONAL_TESTING),
    ])
    return suite

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')

---------------------------------------------------->8-----------------------------------------------------


What is that '_p_jar' attribute?

My test fixture is a subclass of plone.app.testing.PloneSandboxLayer,
AFAICT, I should not have any problem with persistency or stuff like that.

any hints?


-- 
---
Noe Nieto
NNieto Consulting Services
M: [email protected]
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers

Reply via email to