In a Django project I have tests that check that a URL uses a specific class-based view. e.g. I have this view:
from django.views.generic import TemplateView
class HomeView(TemplateView):
template_name = "home.html"
And this test:
from django.test import TestCase
from django.urls import resolve
from myapp import views
class UrlsTestCase(TestCase):
def test_home_view(self):
self.assertEqual(resolve("/").func.__name__, views.HomeView.__name__)
This test passes in Django 3.x but once I try it with Django 4.0 the test fails with:
self.assertEqual(resolve("/").func.__name__, views.HomeView.__name__)
AssertionError: 'view' != 'HomeView'
- view
+ HomeView
Obviously something has changed in Django 4.0 but I can't see anything related in the release notes.
So, what's changed and how can I make this test work again (or how can I test this in a better way)?