def _test_diff_date(self, d1, d2, same):
        diff = AsTextDiff(DummyType(d1), DummyType(d2), "date")
        self.assertTrue(IDifference.providedBy(diff))
        self.assertEqual(diff.same, same)

        inline_diff = diff.inline_diff()
        if same:
            self.assertFalse(inline_diff)
        else:
            self.assertTrue(inline_diff)
            if d1 is not None:
                self.assertTrue(str(d1) in inline_diff)
            if d2 is not None:
                self.assertTrue(str(d2) in inline_diff)
    def _parseField(self, value, filename=None):
        if value is None:
            value = ''
        elif self._vocabulary is not None:
            value = title_or_value(self._vocabulary, value)

        return AsTextDiff._parseField(self, value, filename)
    def _parseField(self, value, filename=None):
        if value is None:
            value = ''
        elif self._vocabulary is not None:
            value = title_or_value(self._vocabulary, value)

        return AsTextDiff._parseField(self, value, filename)
    def __init__(self, obj1, obj2, field, id1=None, id2=None, field_name=None,
                 field_label=None, schemata=None):
        AsTextDiff.__init__(self, obj1, obj2, field, id1, id2, field_name,
                            field_label, schemata)
        self._vocabulary = None

        # Tries to find a vocabulary. First we need to find an object and
        # the field instance.
        obj = obj1 if (obj1 is not None) else obj2
        field_name = field_name or field
        field_instance = (
            get_field_object(obj, field_name) if (obj and field_name)
            else None
        )

        if field_instance is not None:
            # Binding the field to an object will construct the vocabulary
            # using a factory if necessary.
            self._vocabulary = field_instance.bind(obj).vocabulary
    def _parseField(self, value, filename=None):
        value = unicode('' if (value is None) else value)

        # In tests translation is not available, so we account for this
        # case here.
        translate = getattr(getSite(), 'translate', None)
        if translate is not None:
            value = translate(_(value))

        return AsTextDiff._parseField(self, value, filename)
    def __init__(self,
                 obj1,
                 obj2,
                 field,
                 id1=None,
                 id2=None,
                 field_name=None,
                 field_label=None,
                 schemata=None):
        AsTextDiff.__init__(self, obj1, obj2, field, id1, id2, field_name,
                            field_label, schemata)
        self._vocabulary = None

        # Tries to find a vocabulary. First we need to find an object and
        # the field instance.
        obj = obj1 if (obj1 is not None) else obj2
        field_name = field_name or field
        field_instance = (get_field_object(obj, field_name) if
                          (obj and field_name) else None)

        if field_instance is not None:
            # Binding the field to an object will construct the vocabulary
            # using a factory if necessary.
            self._vocabulary = field_instance.bind(obj).vocabulary