-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Overly loud tests in the development environment #1681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report! I don't have a good answer right away. I certainly prefer too much logging to no logging at all in development. It's not good that this isn't mentioned in the changelog though, that's for sure. Can this issue be fixed (or worked around) by adding (or removing) some logging configuration in your project? I have to admit that I'm a bit surprised because I have the toolbar installed everywhere these days and have never seen this behavior; but I'm at loss as to what the difference between our setups may be. If you find an easy solution (or anybody else!) we should definitely retroactively add this to the release notes, or maybe even to the installation instructions. |
I'm having difficulty reproducing this as well. @interDist could you show us how you add the toolbar into your middleware and installed apps in your settings as well as how you're including the toolbar's urls? Include any protecting if statements. |
Sure. Here is our configuration.
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'dnt.middleware.DoNotTrackMiddleware',
'core.middleware.AccountFlagsMiddleware',
]
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins_important_bits': {
'level': 'WARNING',
'class': 'django.utils.log.AdminEmailHandler',
},
'mail_admins_severe_bits': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
},
},
'loggers': {
'my_project': {
'handlers': ['mail_admins_severe_bits'],
},
'my_project.auth': {
'handlers': ['mail_admins_important_bits'],
'propagate': False,
},
},
}
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE.insert(
[i for i, mw in enumerate(MIDDLEWARE) if mw.startswith('django')][-1] + 1,
'debug_toolbar.middleware.DebugToolbarMiddleware'
)
DEBUG_TOOLBAR_CONFIG = {
'JQUERY_URL': '/static/js/jquery.min.js',
'DISABLE_PANELS': {
'debug_toolbar.panels.redirects.RedirectsPanel',
},
'SHOW_TOOLBAR_CALLBACK': 'my_project.debug.show_debug_toolbar',
}
def show_debug_toolbar(request):
return bool(settings.DEBUG)
urlpatterns = [
...
]
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
] The tests are run using unittest. |
Do you run your tests using |
Well, when I am writing / updating the tests, I am doing it in the development environment. Also, when updating a piece of code I would want to first run the related tests, in dev env, to check I did not break anything, right? I suppose I could use However, nothing of it is documented in the docs (usage of the |
@interDist sorry for not responding earlier. Yes you want to run your tests on your local machine, but I believe they should be run with your production configuration, meaning If you (or you @Shriukan33) could create a minimal project that reproduces this effect that would be extremely helpful to us. There is the |
Closes django-commons#1683, closes django-commons#1681, closes django-commons#1119, closes django-commons#906, closes django-commons#695.
We recently went through an upgrade of Django and Python, including the supporting tools, and suddenly our tests started outputting lots of extra information (that was not there before), when run in the development environment. After countless hours trying to find the source of the output, I finally discovered that DDT now adds a
lastResort
handler to the root logger. This change, implemented in #1603, is fairly recent (merged 6 months ago) and, unfortunately, is not documented in the changelog.The difference between the development environment and the CI testing environment is, of course, that in the CI flow DDT is not installed.
How can DDT be updated so as to avoid all the verbose output being printed, when tests are run?
The text was updated successfully, but these errors were encountered: