Closed idgserpro closed 9 years ago
Running setupCoreSessions(app) in the setUpZope handler of your Plone testing layer is the inteded behavior AFAIK.
This is really confusing to beginners. Zope2 is already a dependency in plone.app.testing, wouldn't it be nice to call setupCoreSessions
in plone.app.testing layer lifecycle, for example in setUp
?
I don't know the exact reason but I guess it is because sessions was removed from Plone to be more scaleable and it would be an overhead in most testing scenarios anyways.
idgserpro notifications@github.com schrieb am Do., 25. Juni 2015 um 17:15:
This is really confusing to beginners. Zope2 is already a dependency in plone.app.testing, wouldn't it be nice to call setupCoreSessions in plone.app.testing layer lifecycle, for example in setUp?
— Reply to this email directly or view it on GitHub https://github.com/plone/plone.app.testing/issues/14#issuecomment-115289061 .
it would be an overhead in most testing scenarios anyways.
Well, that's true. But, IMHO, if it's a small overhead, taking it for granted instead of explicity forcing users to call setupCoreSessions
is preferred, mainly because this step is only needed when I'm in using the testing machinery.
I still think that some stuff in plone.app.testing that now is explicity needed to be set (like session or default workflows for content types) should be take for granted, but overridable somehow for those cases that it shouldn't be, to avoid these WTF moments for new Plone users.
Well, this would be hard to implement and this opinion isn't the scope of this issue. They are just my 0.02c. Thanks anyway.
I agree that it is sometimes hard (even for long time Plone users) to figure out what is given and what is not in unittests but the general philosophy of unittests is to start with the minimal possible configuration and add stuff as needed. The usage of session should at least be properly documented. I filed a corresponding issue.
We are doing some tests using robotsframework and plone.app.testing in collective.myproduct that has collective.mydependency as a dependency. This dependency adds some functionality to the login form. This dependency is loaded via zcml in tests and it's profile installed as well (it's in collective.myproduct metadata.xml).
In this functionality, we ask for
self.request.SESSION
, that works fine in Plone, but gives an error when runningbin/test
:Doing a little googling (thanks https://github.com/collective/collective.whathappened/commit/367159ad7a2376677ebc6fb901d47414dda3d4f3), we found out that you have to import
and in the end of setUpZope set
Is this the intended behavior? Isn't plone.app.testing supposed to handle SESSION in
PloneSandboxLayer
?