Example #1
0
    def tearDown(self):
        from wagtail.tests.testapp.models import DefaultRichBlockFieldPage
        from wagtail.tests.testapp.models import DefaultRichTextFieldPage

        DefaultRichTextFieldPage.get_edit_handler()._form_class = None

        block_page_edit_handler = DefaultRichBlockFieldPage.get_edit_handler()
        if block_page_edit_handler._form_class:
            rich_text_block = block_page_edit_handler._form_class.base_fields['body'].block.child_blocks['rich_text']
            if hasattr(rich_text_block, 'field'):
                del rich_text_block.field
        block_page_edit_handler._form_class = None
Example #2
0
    def tearDown(self):
        from wagtail.tests.testapp.models import DefaultRichBlockFieldPage
        from wagtail.tests.testapp.models import DefaultRichTextFieldPage

        DefaultRichTextFieldPage.get_edit_handler()._form_class = None

        block_page_edit_handler = DefaultRichBlockFieldPage.get_edit_handler()
        if block_page_edit_handler._form_class:
            rich_text_block = block_page_edit_handler._form_class.base_fields[
                'body'].block.child_blocks['rich_text']
            if hasattr(rich_text_block, 'field'):
                del rich_text_block.field
        block_page_edit_handler._form_class = None
Example #3
0
    def _clear_edit_handler_cache(self):
        """
        These tests generate new EditHandlers with different settings. The
        cached edit handlers should be cleared before and after each test run
        to ensure that no changes leak through to other tests.
        """
        from wagtail.tests.testapp.models import DefaultRichBlockFieldPage

        rich_text_block = (DefaultRichBlockFieldPage.get_edit_handler(
        ).get_form_class().base_fields['body'].block.child_blocks['rich_text'])
        if hasattr(rich_text_block, 'field'):
            del rich_text_block.field

        for page_class in get_page_models():
            page_class.get_edit_handler.cache_clear()
Example #4
0
    def _clear_edit_handler_cache(self):
        """
        These tests generate new EditHandlers with different settings. The
        cached edit handlers should be cleared before and after each test run
        to ensure that no changes leak through to other tests.
        """
        from wagtail.tests.testapp.models import DefaultRichBlockFieldPage

        rich_text_block = (DefaultRichBlockFieldPage.get_edit_handler()
                           .get_form_class().base_fields['body'].block
                           .child_blocks['rich_text'])
        if hasattr(rich_text_block, 'field'):
            del rich_text_block.field

        for page_class in get_page_models():
            page_class.get_edit_handler.cache_clear()