-
Notifications
You must be signed in to change notification settings - Fork 11
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
Test Views Render Templates #1182
Comments
Are you saying that request factory tests don't actually render the template? |
Correct, you have to access |
Yikes. Feels like a bit of a shortcoming in request factories. Could we make our own request factory that automatically calls |
If you're used to using Client, maybe? RequestFactory generates a request, nothing more. You then use that to test a view with. Views, GCBVs in particular, do not render content by default, they instantiate the configured response class (typically TemplateResponse) and return that instance. I'd rather we didn't have every unit test render templates, that's going to eat up quite a bit of test time. |
I see now that this couldn't work! Have you seen https://github.com/nedbat/django_coverage_plugin? |
I haven't, happy to give it a go though! |
FWIW I just ran:
This changed 95 tests, and the time to run the full suite did not change. |
That is very unexpected, but good to know, can you do that same sed, but add the rendered content check after the 200 so we get both? |
#1181 showed that we weren't testing the configured template existed. Ideally we wouldn't require each view had a unit test for this as it's easily prone to human error.
Can we add a test with subtests which tries to exercise
response.rendered_content
for every view that responds to GET and with a 200?The text was updated successfully, but these errors were encountered: