On Sat, Jul 16, 2011 at 10:13 AM, Martin Aspeli <[email protected]> wrote: > On 14 July 2011 14:06, Rafael Oliveira <[email protected]> wrote: >> Hi, >> >> I'm using plone.app.testing to do some functional testing using >> zope.testbrowser. According to the PyPI documentation of p.a.testing I >> have to call transaction.commit() whenever I add content to the Plone >> Site and want to inspect it in the testbrowser. However, when I do >> this it seems the changes I make to ZODB are not cleaned up when the >> test layer is thorn down. >> >> Example: I create a content item in a test and call >> transaction.commit(). In another test, of another package, belonging >> to a different layer, I can retrieve the same content item. All layers >> and tests are wrote in the standard way prescribed in p.a.testing >> documentation on PyPI. >> >> Is this the expected behavior or am I doing something wrong ? Do I >> have to manualy undo every change to ZODB if I use >> transaction.commit() ? > > You shouldn't have to. > >> Code: >> http://dev.plone.org/collective/browser/collective.cmfeditionsdexteritycompat/trunk/collective/cmfeditionsdexteritycompat > > I wonder if this may be a sequencing issue: Instead of doing > transaction.commit() in setUp(), try to do it in the test_* method > before the call to browser.open(). > > It's also useful to look at the test runner output to see which order > it's setting up the layers in. The FunctionalTesting() layer basically > stacks a DemoStorage for each and every test (in its testSetUp() > method) and pops it in testTearDown(), which is how we get isolation. > If your own setUp() or any other transaction commit is running before > the stacking, you'll be committing to the underlying DemoStorage, > which would then be shared between tests. >
I see. I did the changes and it worked. Thanks ! Rafael Bruno Cavalhero de Oliveira Analista de Desenvolvimento de Sistemas - SERPRO http://rafaelb.objectis.net _______________________________________________ Product-Developers mailing list [email protected] https://lists.plone.org/mailman/listinfo/plone-product-developers
