ERP5Type/tests: review requests in tests
The general idea of this patch is that now that we are using zope.globalrequest, we no longer need to patch get_request, we can simply call zope.globalrequest.setRequest with the request from the test and restore the "real" request afterwards. To achieve this, we reuse Testing.ZopeTestCase.connections.registry, which already has the logic of cleaning up resources in the right place and use a "Request" resource that calls setRequest(test_request) and setRequest(real_request) when closed, so that: - test runs with an independant request - this test request is closed at the end - the real request is restored at the end This also fixes a bug with self.publish when runnning ERP5TypeLiveTestCase from portal_components of a running instance, after a call to self.publish the current request was lost. The testing for this revealed that ERP5TypeLiveTestCase.publish way of dealing with zope.security interaction was not always correct: when running a live test inside runUnitTest (like we do here in testDynamicClassGeneration), there is no security interaction. This was reviewed to use the high level API instead of changing directly the internal storage.
Showing