django-hilbert
django-hilbert copied to clipboard
url_name for ViewTestMixin confusion
This doc: http://django-hilbert.readthedocs.org/en/v0.4.1/test.html#viewtestmixin
leads me to believe I need to specify 'url_name' for my test class. But when I do that I get:
AttributeError: 'HomePageTest' object has no attribute 'url'
If I change my url_name to url, the test case runs. I'm not sure whether the code or doc is off. Using 0.4.1 level.
self.url is constructed in the ViewTestMixin.__init__. There might be a problem related to depending on where the mixin is used in the base classes and whether or not super is called. This could problem could probably be removed by making it a property instead.
Actually it seems to be done in setUp. And whether setUp is called differs depending on whether my class is declared:
class DashboardTestCase(TestCase, ViewTestMixin):
url_name = 'sepc_home'
vs:
class DashboardTestCase(ViewTestMixin, TestCase):
url_name = 'sepc_home'
The latter works, the former does not. Possibly due to: https://code.djangoproject.com/ticket/15828
Yes I just saw I wrote __init__ rather than setUp.
Started some work on this in the feature/refactor-view-mixin.