plone / plone.app.viewletmanager

TTW configurable viewlet manager for Plone
https://pypi.org/project/plone.app.viewletmanager
1 stars 4 forks source link

RFC: Do not swallow viewlet rendering errors during test #24

Open mauritsvanrees opened 3 years ago

mauritsvanrees commented 3 years ago

I ran into an issue while testing an improvement in plone.app.iterate. While trying it out manually, the main feature seemed to work, but the main navigation viewlet gave an error, leading to an error text on the page:

error while rendering plone.global_sections

I don't know if there are browser tests for this particular case in plone.app.iterate, but for the sake of argument, let's say there are. (Also assume that it is not a stupid error by me.) Then it would be nice if this error would have been caught by running the tests. Currently, what happens is that errors in viewlets get caught and ignored by this code and similar code a few lines below. The page shows a small error message on one part of the page, but the rest is rendering fine. That seems a good idea in production use.

But while running tests, I think in most cases it would be useful to throw an error. In the tests, when the page returns a '200 OK' status, you assume everything is fine. You don't go looking for 'error while rendering' in the browser contents. And if you do, then you still don't know what the real error is. It would be useful to be able to switch this error swallowing off. Some options:

  1. Detect that bin/test is running and change the behavior.
  2. Look for an OS environment variable SWALLOWING_ERRORS_MAKES_MY_TUMMY_ACHE (or something less interesting) and raise the error explicitly then. Set this OS variable somewhere, maybe in plone.app.testing.
  3. We could additionally enable this automatically when the instance runs in the foreground. Or this changes the default, and you can explicitly set it with the environment variable.

Number 2 is probably best, with number 3 as addition.

For the moment this is just an idea. I don't yet have an urge to work on this. But it would be interesting to know if others think this is a good idea.