<commit_before>from __future__ import absolute_import, unicode_literals

import unittest

from django.test import TestCase
from django.utils.functional import curry
from django.utils.safestring import SafeText

from wagtail.tests.testapp.models import EventPage, EventPageSpeaker, SimplePage, StreamPage, TaggedPage
from wagtail.wagtailadmin import compare
from wagtail.wagtailcore.blocks import StreamValue
from wagtail.wagtailcore.models import Page
from wagtail.wagtailimages.models import get_image_model
from wagtail.wagtailimages.tests.utils import get_test_image_file


class TestFieldComparison(TestCase):
    comparison_class = compare.FieldComparison

    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(), SafeText)
        self.assertFalse(comparison.has_changed())

    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(), SafeText)
        self.assertTrue(comparison.has_changed())<commit_msg>Use non-deprecated import for get_image_model<commit_after>from __future__ import absolute_import, unicode_literals

import unittest

from django.test import TestCase
from django.utils.functional import curry
from django.utils.safestring import SafeText

from wagtail.tests.testapp.models import EventPage, EventPageSpeaker, SimplePage, StreamPage, TaggedPage
from wagtail.wagtailadmin import compare
from wagtail.wagtailcore.blocks import StreamValue
from wagtail.wagtailcore.models import Page
from wagtail.wagtailimages import get_image_model
from wagtail.wagtailimages.tests.utils import get_test_image_file


class TestFieldComparison(TestCase):
    comparison_class = compare.FieldComparison

    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(), SafeText)
        self.assertFalse(comparison.has_changed())

    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(), SafeText)
        self.assertTrue(comparison.has_changed())
{'fraction_non_alphanumeric': 0.09161179501860865, 'fraction_numerical': 0.0, 'mean_word_length': 4.238380809595203, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1875944', 'n_tokens_mistral': 963, 'n_tokens_neox': 917, 'n_words': 173}