These are the two apps in my INSTALLED_APPS list which is giving me a problem.
- django.contrib.messages
- sentry.client
One unit test in particular is doing an assertRaises expecting a django.contrib.messages.api.MessageFailure.
sentry.client installs a signal handler that listens for got-request-exception.
During the test execution, the signal handler attempts to log the exception to sentry & this cause sentry.client to fail with a HTTP Error 400: BAD REQUEST. The sentry code says that it will avoid the logging if the exception type possesses an attribute “.
Where can I monkeypatch django.contrib.messages.api.MessageFailure like so:
MessageFailure.skip_sentry = True
Obviously I don’t want to change the django test sources.
I haven’t used sentry before, but to add a
skip_entryattribute to theMessageFailureclass you use a mix-in. Add the following code in a module that’s guaranteed to run when your Django server starts up [anymodels.pyshould work]: