-
Notifications
You must be signed in to change notification settings - Fork 7
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
Settings module + Browsable API and debug settings #84
Conversation
c3fe7ab
to
85ff7ba
Compare
@@ -8,44 +8,32 @@ def pytest_configure(): | |||
from django.conf import settings | |||
|
|||
settings.configure( | |||
SECRET_KEY="secret", | |||
DEBUG=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun. This was never actually True
. Seems configure
cannot override the default from global_settings
.
399d1ca
to
3f1a175
Compare
3f1a175
to
543e994
Compare
INSTALLED_APPS=[ | ||
"django.contrib.admin", | ||
"django.contrib.auth", | ||
"django.contrib.contenttypes", | ||
"django.contrib.sessions", | ||
"django.contrib.messages", | ||
"django.contrib.staticfiles", | ||
"tests", | ||
"worf", | ||
], | ||
MIDDLEWARE=[ | ||
"django.middleware.common.CommonMiddleware", | ||
"django.contrib.sessions.middleware.SessionMiddleware", | ||
"django.contrib.auth.middleware.AuthenticationMiddleware", | ||
"django.contrib.messages.middleware.MessageMiddleware", | ||
], | ||
ROOT_URLCONF="tests.urls", | ||
DATABASES={ | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": "db.sqlite3", | ||
} | ||
}, | ||
INSTALLED_APPS=[ | ||
"django.contrib.auth", | ||
"django.contrib.contenttypes", | ||
"tests", | ||
"worf", | ||
], | ||
PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"], | ||
ROOT_URLCONF="tests.urls", | ||
TEMPLATES = [ | ||
{ | ||
"BACKEND": "django.template.backends.django.DjangoTemplates", | ||
"APP_DIRS": True, | ||
}, | ||
], | ||
TIME_ZONE="UTC", | ||
USE_I18N=True, | ||
USE_L10N=True, | ||
USE_I18N=False, | ||
USE_L10N=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stripped some of this down given it doesn't matter and/or saves on cpu.
if settings.WORF_DEBUG: | ||
try: | ||
self.query = str(queryset.query) | ||
except EmptyResultSet: | ||
self.query = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might have seen this exception when using filters that create an impossible query. Outside of debug mode lists will yield []
but when debug mode is on they'd fail here trying to output the sql for the debug.
The reason I've addressed this here is because now that debug mode is actually on during testing, one test was failing here given it exercises an impossible query.
Wraps settings up into their own module for visibility, and adds an option to disable browsable api and debug mode.
Also switches testing to exercise debug mode, which seemingly wasn't happening (+0.5% coverage) and fixes a bug where
EmptyResultSet
would throw when trying to render the sql for the debug output.What Worf gif best describes this PR or how it makes you feel?
Checklist
README
updates reflecting any new features/improvements to the framework