-
Notifications
You must be signed in to change notification settings - Fork 1
adds in sample pytest #30
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| urlpatterns += [ | ||
| url(r'^__debug__/', include(debug_toolbar.urls)), | ||
| re_path(r'^__debug__/', include(debug_toolbar.urls)), |
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.
I think path might be more appropriate (and remove the regex components): https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#add-the-urls
| pytest | ||
| {%- if cookiecutter.feature_annotations == "on" %} |
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.
I think we also need pytest-django
| class TestClass: | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "url_name, url, view_class", | ||
| [ | ||
| ("index", "/", views.IndexView), | ||
| ], | ||
| ) | ||
| def test_urls(self, url_name, url, view_class): | ||
| resolver = resolve(url) | ||
| assert resolver.view_name == url_name | ||
| assert resolver.func.view_class == view_class |
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.
This definitely handles the use case of giving people a sample to follow, but it would be more ideal to have a sample that 1. uses the database, and 2. tests something that is code we've written and not django code
Maybe we can create a new view that uses LoginRequiredMixin and test access that requires the use of factories and making database calls?
There are still warnings present
RemovedInDjango41Warning: 'django_extensions' defines default_app_config = 'django_extensions.apps.DjangoExtensionsConfig'. Django now detects this configuration automatically. You can remove default_app_config.It seems to be that two packages that we use (
django_extensionsandwebpack_loader) definedefault_app_config, which is not needed anymore. We might have to wait for a new version for them to remove itResolves #29