hi ! I've the following problems using ZopeTestCase (0.8.6) : - when I add a second "test" method to a ZTC based test case, I get the following traceback (the first test succeed) : Traceback (most recent call last): File "/usr/lib/zope/lib/python/Testing/ZopeTestCase/ZopeTestCase.py", line 105, in setUp self._setupFolder() File "/usr/lib/zope/lib/python/Testing/ZopeTestCase/ZopeTestCase.py", line 124, in _setupFolder self.app.manage_addFolder(folder_name) File "/usr/lib/zope/lib/python/OFS/Folder.py", line 46, in manage_addFolder self._setObject(id, ob) File "/usr/lib/zope/lib/python/OFS/ObjectManager.py", line 244, in _setObject v=self._checkId(id) File "/usr/lib/zope/lib/python/OFS/ObjectManager.py", line 77, in checkValidId raise BadRequestException, ('The id "%s" is invalid--' Bad Request: The id "test_folder_1_" is invalid--it is already in use. Note I don't have a tearDown method defined in my own test classe. - I'm using ZopeTestCase in combinaison with mechanicalcat [1] to do some functionnal tests. Using mechanicalcat to post a form which leads to some objects modifications (objects which had have been created in the afterSetUp method) works fine. The problem is that if I access to those objects using self.app, I get the old version of the object, but I get the updated version using self._app(). I guess I'm missing something with both problem... Any idea ? [1] http://www.mechanicalcat.net/tech/webunit/ -- Sylvain Thénault LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org
Hello Sylvain, The "Bad Request" is usually a sign that you are committing in afterSetUp(). You *may* do that, but only if you override beforeClose() to commit the cleaned-up state as well. Also see the testWebserver.py example test. Webunit uses a separate ZODB connection from the one ZTC opens for its tests. If you want to see the changes made by the webunit request, you have to call self._app() again. There is nothing wrong with that. hth, Stefan On Mittwoch, Jän 21, 2004, at 15:36 Europe/Vienna, Sylvain Thénault wrote:
Bad Request: The id "test_folder_1_" is invalid--it is already in use.
Note I don't have a tearDown method defined in my own test classe.
- I'm using ZopeTestCase in combinaison with mechanicalcat [1] to do some functionnal tests. Using mechanicalcat to post a form which leads to some objects modifications (objects which had have been created in the afterSetUp method) works fine. The problem is that if I access to those objects using self.app, I get the old version of the object, but I get the updated version using self._app().
I guess I'm missing something with both problem... Any idea ?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
On Wednesday 21 January à 19:15, Stefan H. Holek wrote:
Hello Sylvain,
Hi Stefan
The "Bad Request" is usually a sign that you are committing in afterSetUp(). You *may* do that, but only if you override beforeClose() to commit the cleaned-up state as well. Also see the testWebserver.py example test.
ok, I've overriden beforeClose() to delete the portal object and to commit the cleaned-up state, that's working now :) Thanks !
Webunit uses a separate ZODB connection from the one ZTC opens for its tests. If you want to see the changes made by the webunit request, you have to call self._app() again. There is nothing wrong with that.
Ok. However, I still feel unconfortable with this behaviour. Would you or someone else knows about a document or whatever that could put me in the picture ? Thanks again for your quick answer. -- Sylvain Thénault LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org
participants (2)
-
Stefan H. Holek -
Sylvain Thénault