assertLoginRequired does not work in CBVTestCase
rubickcz opened this issue · comments
Hello,
I am getting following error, when calling self.assertLoginRequired('user_list')
in a class that inherits from CBVTestCase
:
Traceback (most recent call last):
File "/home/ondra/projects/attendance/attendance/users/tests/test_views.py", line 33, in test_login_required
self.get('user_list')
File "/home/ondra/other/venvs/attendance/lib/python3.6/site-packages/test_plus/test.py", line 436, in get
instance = self.get_instance(cls, initkwargs=initkwargs, request=request, **kwargs)
File "/home/ondra/other/venvs/attendance/lib/python3.6/site-packages/test_plus/test.py", line 420, in get_instance
instance = cls(**initkwargs)
TypeError: 'str' object is not callable
This seems to be caused by the fact that get()
method looks different in TestCase
and CBVTestCase
:
# TestCase
def get(self, url_name, *args, **kwargs):
# CBVTestCase
def get(self, cls, *args, **kwargs)
assertLoginRequired()
method is only defined in TestCase
class, so it expects a different get()
method signature and passes string (intended to be url_name
) as cls
paramter.
Good catch @rubickcz! I've submitted a PR which fixes this problem as well as same for a few other test methods. Thanks for the report.