Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _pre_setup(self, *args, **kwargs):
super(ViewTestCaseMixin, self)._pre_setup(*args, **kwargs)
if self.factory_class:
self.factory = self.factory_class(self.get_middleware_classes())
def _get_view(self, request):
if self.view_class:
view = self.view_class.as_view(**self.get_view_kwargs())
elif self.view_function:
view = self.__class__.__dict__['view_function']
else:
raise Exception('Missing view_class or view_function or viewset')
return view
class ViewTransactionTestCase(ViewTestCaseMixin, django_test.TransactionTestCase):
pass
class ViewTestCase(ViewTestCaseMixin, django_test.TestCase):
pass
if django.VERSION >= (1, 4):
class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase):
pass
if django.VERSION >= (1, 5):
class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase):
pass
else:
raise Exception('Missing view_class or view_function or viewset')
return view
class ViewTransactionTestCase(ViewTestCaseMixin, django_test.TransactionTestCase):
pass
class ViewTestCase(ViewTestCaseMixin, django_test.TestCase):
pass
if django.VERSION >= (1, 4):
class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase):
pass
if django.VERSION >= (1, 5):
class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase):
pass
response = view(request, *self.args, **self.kwargs)
return response
def _get_view(self, request):
if self.view_class:
view = self.view_class.as_view(**self.get_view_kwargs())
elif self.view_function:
view = self.__class__.__dict__['view_function']
else:
raise Exception('Missing view_class or view_function or viewset')
return view
class ViewTransactionTestCase(ViewTestCaseMixin, django_test.TransactionTestCase):
pass
class ViewTestCase(ViewTestCaseMixin, django_test.TestCase):
pass
if django.VERSION >= (1, 4):
class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase):
pass
if django.VERSION >= (1, 5):
class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase):
pass
class ViewTransactionTestCase(ViewTestCaseMixin, django_test.TransactionTestCase):
pass
class ViewTestCase(ViewTestCaseMixin, django_test.TestCase):
pass
if django.VERSION >= (1, 4):
class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase):
pass
if django.VERSION >= (1, 5):
class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase):
pass