Python django.utils.safestring.SafeString() Examples

The following are 30 code examples for showing how to use django.utils.safestring.SafeString(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.utils.safestring , or try the search function .

Example 1
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_hasnt_changed(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
            ])),
        )

        self.assertTrue(comparison.is_field)
        self.assertFalse(comparison.is_child_relation)
        self.assertEqual(comparison.field_label(), "Body")
        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Content</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertFalse(comparison.has_changed()) 
Example 2
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_has_changed(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Original content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Modified content", '1'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object"><span class="deletion">Original</span><span class="addition">Modified</span> content</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 3
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_delete_block(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
                ('text', "Content Foo", '2'),
                ('text', "Content Bar", '3'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
                ('text', "Content Bar", '3'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Content</div>\n<div class="comparison__child-object deletion">Content Foo</div>\n<div class="comparison__child-object">Content Bar</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 4
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_edit_block(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
                ('text', "Content Foo", '2'),
                ('text', "Content Bar", '3'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Content", '1'),
                ('text', "Content Baz", '2'),
                ('text', "Content Bar", '3'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Content</div>\n<div class="comparison__child-object">Content <span class="deletion">Foo</span><span class="addition">Baz</span></div>\n<div class="comparison__child-object">Content Bar</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 5
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_has_changed_richtext(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "<b>Original</b> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "Modified <i>content</i>", '1'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object"><span class="deletion">Original</span><span class="addition">Modified</span> content</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 6
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_htmldiff_escapes_value_on_addition(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Original <em>and unchanged</em> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "Original <em>and unchanged</em> content", '1'),
                ('text', '<script type="text/javascript">doSomethingBad();</script>', '2'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Original &lt;em&gt;and unchanged&lt;/em&gt; content</div>\n<div class="comparison__child-object addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 7
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_htmldiff_richtext_strips_tags_on_addition(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "Original <em>and unchanged</em> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "Original <em>and unchanged</em> content", '1'),
                ('rich_text', 'I <b>really</b> like evil code &gt;_&lt; <script type="text/javascript">doSomethingBad();</script>', '2'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Original and unchanged content</div>\n<div class="comparison__child-object addition">I really like evil code &gt;_&lt; doSomethingBad();</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 8
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_htmldiff_richtext_strips_tags_on_deletion(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "Original <em>and unchanged</em> content", '1'),
                ('rich_text', 'I <b>really</b> like evil code &gt;_&lt; <script type="text/javascript">doSomethingBad();</script>', '2'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "Original <em>and unchanged</em> content", '1'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Original and unchanged content</div>\n<div class="comparison__child-object deletion">I really like evil code &gt;_&lt; doSomethingBad();</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 9
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_compare_structblock(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('product', {'name': 'a packet of rolos', 'price': '75p'}, '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('product', {'name': 'a packet of rolos', 'price': '85p'}, '1'),
            ])),
        )

        expected = """
            <div class="comparison__child-object"><dl>
                <dt>Name</dt>
                <dd>a packet of rolos</dd>
                <dt>Price</dt>
                <dd><span class="deletion">75p</span><span class="addition">85p</span></dd>
            </dl></div>
        """
        self.assertHTMLEqual(comparison.htmldiff(), expected)
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 10
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_hasnt_changed(self):
        a = TaggedPage()
        a.tags.add('wagtail')
        a.tags.add('bird')

        b = TaggedPage()
        b.tags.add('wagtail')
        b.tags.add('bird')

        comparison = self.comparison_class(TaggedPage._meta.get_field('tags'), a, b)

        self.assertTrue(comparison.is_field)
        self.assertFalse(comparison.is_child_relation)
        self.assertEqual(comparison.field_label(), "Tags")
        self.assertEqual(comparison.htmldiff(), 'wagtail, bird')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertFalse(comparison.has_changed()) 
Example 11
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_hasnt_changed(self):
        christmas_event = EventPage.objects.get(url_path='/home/events/christmas/')
        saint_patrick_event = EventPage.objects.get(url_path='/home/events/saint-patrick/')

        christmas_event.categories = [self.meetings_category, self.parties_category]
        saint_patrick_event.categories = [self.meetings_category, self.parties_category]

        comparison = self.comparison_class(
            EventPage._meta.get_field('categories'), christmas_event, saint_patrick_event
        )

        self.assertTrue(comparison.is_field)
        self.assertFalse(comparison.is_child_relation)
        self.assertEqual(comparison.field_label(), "Categories")
        self.assertFalse(comparison.has_changed())
        self.assertEqual(comparison.htmldiff(), 'Meetings, Parties')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 12
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: base.py    License: Apache License 2.0 6 votes vote down vote up
def _cursor(self):
    if not self._valid_connection():
      kwargs = {'conv': base.django_conversions, 'dsn': None}
      settings_dict = self.settings_dict
      settings_dict.update(settings_dict.get('OPTIONS', {}))
      for settings_key, kwarg, required in _SETTINGS_CONNECT_ARGS:
        value = settings_dict.get(settings_key)
        if value:
          kwargs[kwarg] = value
        elif required:
          raise exceptions.ImproperlyConfigured(
              "You must specify a '%s' for database '%s'" %
              (settings_key, self.alias))
      self.connection = Connect(**kwargs)
      encoders = {safestring.SafeUnicode: self.connection.encoders[unicode],
                  safestring.SafeString: self.connection.encoders[str]}
      self.connection.encoders.update(encoders)
      signals.connection_created.send(sender=self.__class__, connection=self)
    cursor = base.CursorWrapper(self.connection.cursor())
    return cursor 
Example 13
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_hasnt_changed(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content="Content"),
            SimplePage(content="Content"),
        )

        self.assertTrue(comparison.is_field)
        self.assertFalse(comparison.is_child_relation)
        self.assertEqual(comparison.field_label(), "Content")
        self.assertEqual(comparison.htmldiff(), 'Content')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertFalse(comparison.has_changed()) 
Example 14
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content="Original content"),
            SimplePage(content="Modified content"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original content</span><span class="addition">Modified content</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 15
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_escapes_value(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content='Original content'),
            SimplePage(content='<script type="text/javascript">doSomethingBad();</script>'),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original content</span><span class="addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 16
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content="Original content"),
            SimplePage(content="Modified content"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original</span><span class="addition">Modified</span> content')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 17
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_from_none_to_value_only_shows_addition(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content=None),
            SimplePage(content="Added content")
        )

        self.assertEqual(comparison.htmldiff(), '<span class="addition">Added content</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 18
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content="Original content"),
            SimplePage(content="Modified content"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original</span><span class="addition">Modified</span> content')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed())

    # Only change from FieldComparison is that this comparison disregards HTML tags 
Example 19
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed_html(self):
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content="<b>Original</b> content"),
            SimplePage(content="Modified <i>content</i>"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original</span><span class="addition">Modified</span> content')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 20
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_escapes_value(self):
        # Need to override this one as the HTML tags are stripped by RichTextFieldComparison
        comparison = self.comparison_class(
            SimplePage._meta.get_field('content'),
            SimplePage(content='Original content'),
            SimplePage(content='<script type="text/javascript">doSomethingBad();</script>'),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Original content</span><span class="addition">doSomethingBad();</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 21
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_escapes_value_on_change(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', "I <b>really</b> like original<i>ish</i> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('text', 'I <b>really</b> like evil code <script type="text/javascript">doSomethingBad();</script>', '1'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">I &lt;b&gt;really&lt;/b&gt; like <span class="deletion">original&lt;i&gt;ish&lt;/i&gt; content</span><span class="addition">evil code &lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span></div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 22
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_richtext_strips_tags_on_change(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', "I <b>really</b> like Wagtail &lt;3", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('rich_text', 'I <b>really</b> like evil code &gt;_&lt; <script type="text/javascript">doSomethingBad();</script>', '1'),
            ])),
        )

        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">I really like <span class="deletion">Wagtail &lt;3</span><span class="addition">evil code &gt;_&lt; doSomethingBad();</span></div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 23
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_raw_html_escapes_value_on_change(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('raw_html', "Original<i>ish</i> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('raw_html', '<script type="text/javascript">doSomethingBad();</script>', '1'),
            ])),
        )
        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object"><span class="deletion">Original&lt;i&gt;ish&lt;/i&gt; content</span><span class="addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span></div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 24
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_htmldiff_raw_html_escapes_value_on_addition(self):
        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('raw_html', "Original <em>and unchanged</em> content", '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('raw_html', "Original <em>and unchanged</em> content", '1'),
                ('raw_html', '<script type="text/javascript">doSomethingBad();</script>', '2'),
            ])),
        )
        self.assertEqual(comparison.htmldiff(), '<div class="comparison__child-object">Original &lt;em&gt;and unchanged&lt;/em&gt; content</div>\n<div class="comparison__child-object addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</div>')
        self.assertIsInstance(comparison.htmldiff(), SafeString) 
Example 25
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_compare_imagechooserblock(self):
        image_model = get_image_model()
        test_image_1 = image_model.objects.create(
            title="Test image 1",
            file=get_test_image_file(),
        )
        test_image_2 = image_model.objects.create(
            title="Test image 2",
            file=get_test_image_file(),
        )

        field = StreamPage._meta.get_field('body')

        comparison = self.comparison_class(
            field,
            StreamPage(body=StreamValue(field.stream_block, [
                ('image', test_image_1, '1'),
            ])),
            StreamPage(body=StreamValue(field.stream_block, [
                ('image', test_image_2, '1'),
            ])),
        )

        result = comparison.htmldiff()
        self.assertIn('<div class="preview-image deletion">', result)
        self.assertIn('alt="Test image 1"', result)
        self.assertIn('<div class="preview-image addition">', result)
        self.assertIn('alt="Test image 2"', result)

        self.assertIsInstance(result, SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 26
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_hasnt_changed(self):
        comparison = self.comparison_class(
            EventPage._meta.get_field('audience'),
            EventPage(audience="public"),
            EventPage(audience="public"),
        )

        self.assertTrue(comparison.is_field)
        self.assertFalse(comparison.is_child_relation)
        self.assertEqual(comparison.field_label(), "Audience")
        self.assertEqual(comparison.htmldiff(), 'Public')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertFalse(comparison.has_changed()) 
Example 27
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        comparison = self.comparison_class(
            EventPage._meta.get_field('audience'),
            EventPage(audience="public"),
            EventPage(audience="private"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="deletion">Public</span><span class="addition">Private</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 28
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_from_none_to_value_only_shows_addition(self):
        comparison = self.comparison_class(
            EventPage._meta.get_field('audience'),
            EventPage(audience=None),
            EventPage(audience="private"),
        )

        self.assertEqual(comparison.htmldiff(), '<span class="addition">Private</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 29
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        a = TaggedPage()
        a.tags.add('wagtail')
        a.tags.add('bird')

        b = TaggedPage()
        b.tags.add('wagtail')
        b.tags.add('motacilla')

        comparison = self.comparison_class(TaggedPage._meta.get_field('tags'), a, b)

        self.assertEqual(comparison.htmldiff(), 'wagtail, <span class="deletion">bird</span>, <span class="addition">motacilla</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)
        self.assertTrue(comparison.has_changed()) 
Example 30
Project: wagtail   Author: wagtail   File: test_compare.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_has_changed(self):
        christmas_event = EventPage.objects.get(url_path='/home/events/christmas/')
        saint_patrick_event = EventPage.objects.get(url_path='/home/events/saint-patrick/')

        christmas_event.categories = [self.meetings_category, self.parties_category]
        saint_patrick_event.categories = [self.meetings_category, self.holidays_category]

        comparison = self.comparison_class(
            EventPage._meta.get_field('categories'), christmas_event, saint_patrick_event
        )

        self.assertTrue(comparison.has_changed())
        self.assertEqual(comparison.htmldiff(), 'Meetings, <span class="deletion">Parties</span>, <span class="addition">Holidays</span>')
        self.assertIsInstance(comparison.htmldiff(), SafeString)