diff --git a/djangocms_helper/base_test.py b/djangocms_helper/base_test.py index 19e1378..44aff58 100644 --- a/djangocms_helper/base_test.py +++ b/djangocms_helper/base_test.py @@ -12,7 +12,7 @@ from django.http import SimpleCookie from django.template import RequestContext from django.template.loader import get_template -from django.test import RequestFactory, TestCase +from django.test import RequestFactory, TestCase, TransactionTestCase from django.utils.functional import SimpleLazyObject from django.utils.six import StringIO @@ -26,9 +26,9 @@ from mock import patch -class BaseTestCase(TestCase): +class BaseTestCaseMixin(object): """ - Utils class that provides some helper methods to setup and interact with + Utils mixin that provides some helper methods to setup and interact with Django testing framework. """ request_factory = None @@ -87,7 +87,7 @@ class BaseTestCase(TestCase): @classmethod def setUpClass(cls): from django.contrib.sites.models import Site - super(BaseTestCase, cls).setUpClass() + super(BaseTestCaseMixin, cls).setUpClass() cls.request_factory = RequestFactory() cls.user = create_user( cls._admin_user_username, cls._admin_user_email, cls._admin_user_password, @@ -111,7 +111,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - super(BaseTestCase, cls).tearDownClass() + super(BaseTestCaseMixin, cls).tearDownClass() User = get_user_model() User.objects.all().delete() @@ -523,3 +523,17 @@ def captured_output(self): with patch('sys.stdout', new_callable=StringIO) as out: with patch('sys.stderr', new_callable=StringIO) as err: yield out, err + + +class BaseTestCase(BaseTestCaseMixin, TestCase): + """ + Base class that implements :py:class:`BaseTestCaseMixin` and + :py:class:`django.tests.TestCase` + """ + + +class BaseTransactionTestCase(BaseTestCaseMixin, TransactionTestCase): + """ + Base class that implements :py:class:`BaseTestCaseMixin` and + :py:class:`django.tests.TransactionTestCase` + """ diff --git a/docs/basetest.rst b/docs/basetest.rst index 60d7b1b..d218bbc 100644 --- a/docs/basetest.rst +++ b/docs/basetest.rst @@ -1,7 +1,13 @@ Base test class =============== -.. autoclass:: djangocms_helper.base_test.BaseTestCase +:py:class:`BaseTestCaseMixin` is available to provide helpers and methods that implements +repetitive tasks during development. +:py:class:`BaseTestCase`, :py:class:`BaseTransactionTestCase` are concrete classes extending +:py:class:`django.tests.TestCase` and :py:class:`django.tests.TransactionTestCase` + + +.. autoclass:: djangocms_helper.base_test.BaseTestCaseMixin :members: :private-members: @@ -15,3 +21,8 @@ Base test class .. autoattribute:: djangocms_helper.base_test.BaseTestCase._user_user_password .. autoattribute:: djangocms_helper.base_test.BaseTestCase._user_user_email .. autoattribute:: djangocms_helper.base_test.BaseTestCase._pages_data + + +.. autoclass:: djangocms_helper.base_test.BaseTestCase + +.. autoclass:: djangocms_helper.base_test.BaseTransactionTestCase diff --git a/docs/settings.rst b/docs/settings.rst index d3cb2de..f075570 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -62,13 +62,13 @@ All ``TEMPLATES_`` settings from Django 1.6/1.7 are automatically translated to will take care of converting. Django 1.10 support -================== +=================== ``MIDDLEWARE_CLASSES`` setting is automatically copied into ``MIDDLEWARE`` on Django 1.10 and above to support new style middleware. *This assumes all the middlewares are compatible with the new style.* If you define a ``MIDDLEWARE`` setting, ``MIDDLEWARE_CLASSES`` is **not** copied over it or merged with it, including the django CMS middlewares. To support both styles, thus, just use the old setting and -and the `compatibility mixin`_. +and the `compatibility mixin`_. ================ @@ -151,3 +151,6 @@ Middlewares:: ``djangocms-helper`` discovers automtically the South / Django migrations layout and configure the settings accordingly. As of the current version ``filer``, ``djangocms_text_ckeditor``, ``cmplugin_filer`` are supported. + + +.. _compatibility mixin: https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-middleware