def testGetLineDictDiffsDifferent(self): """test getLineDiffs() method with dict different value""" c = C() d = D() diff = ListDiff(c, d, 'attribute') expected = [('replace', 0, 1, 0, 1)] self.assertEqual(diff.getLineDiffs(), expected)
def testGetLineDiffsDifferent(self): """test getLineDiffs() method with different value""" a = A() b = B() diff = ListDiff(a, b, 'attribute') expected = [('equal', 0, 3, 0, 3), ('insert', 3, 3, 3, 4)] self.assertEqual(diff.getLineDiffs(), expected)
def testDiffText(self): """Test text diff output with no diff""" a = A() b = B() expected = " 1\n 2\n 3\n+ 4" diff = ListDiff(a, b, 'attribute') self.assertEqual(diff.ndiff(), expected)
def testDiffText(self): """Test text diff output with no diff""" a = A() b = B() expected = ' 1%(linesep)s 2%(linesep)s 3%(linesep)s+ 4' % \ {'linesep': linesep} diff = ListDiff(a, b, 'attribute') self.assertEqual(diff.ndiff(), expected)
def testDiffText(self): """Test text diff output with no diff""" a = A() b = B() expected = " 1%(linesep)s 2%(linesep)s 3%(linesep)s+ 4" % \ {'linesep': linesep} diff = ListDiff(a, b, 'attribute') self.assertEqual(diff.ndiff(), expected)
def test_inline_diff(self): a = A() b = B() expected = """<div class="InlineDiff">1</div> <div class="InlineDiff">2</div> <div class="InlineDiff">3</div> <div class="InlineDiff"> <div class="diff_sub"></div> <div class="diff_add">4</div> </div>""" diff = ListDiff(a, b, 'attribute') self.assertEqual(diff.inline_diff(), expected)
def __init__(self, obj1, obj2, field, id1=None, id2=None, field_name=None, field_label=None, schemata=None): ListDiff.__init__(self, obj1, obj2, field, id1, id2, field_name, field_label, schemata) old_values = list(self.oldValue or []) new_values = list(self.newValue or []) self.same = True if len(old_values) != len(new_values): self.same = False else: for (old, new) in zip(old_values, new_values): if not is_same(old, new): self.same = False break
def __init__(self, obj1, obj2, field, id1=None, id2=None, field_name=None, field_label=None, schemata=None): ListDiff.__init__(self, obj1, obj2, field, id1, id2, field_name, field_label, schemata) old_values = list(self.oldValue or []) new_values = list(self.newValue or []) self.same = True if len(old_values) != len(new_values): self.same = False else: for (old, new) in zip(old_values, new_values): if not is_same(old.data, old.filename, new.data, new.filename): self.same = False break
def testInvalidValue(self): """ Test if no error with invalid values """ a = A() a.attribute = [] b = A() b.attribute = None diff = ListDiff(a, b, 'attribute') self.assertEqual([('insert', 0, 0, 0, 1)], diff.getLineDiffs()) b.attribute = 0 diff = ListDiff(a, b, 'attribute') self.assertEqual([('insert', 0, 0, 0, 1)], diff.getLineDiffs()) b.attribute = '' diff = ListDiff(a, b, 'attribute') self.assertEqual([('insert', 0, 0, 0, 1)], diff.getLineDiffs())
def testSameText(self): """Test text diff output with no diff""" a = A() diff = ListDiff(a, a, 'attribute') expected = " 1%(linesep)s 2%(linesep)s 3" % {'linesep': linesep} self.assertEqual(diff.ndiff(), expected)
def _test_diff_list(self, value1, value2, same, expected): self.obj1.choices = value1 self.obj2.choices = value2 diff = ListDiff(self.obj1, self.obj2, 'choices') self.assertEqual(diff.same, same) self.assertEqual(diff.inline_diff(), expected)
def testGetLineDiffsSame(self): """test getLineDiffs() method with same value""" a = A() diff = ListDiff(a, a, 'attribute') expected = [('equal', 0, 3, 0, 3)] self.assertEqual(diff.getLineDiffs(), expected)
def testGetLineDictDiffsSame(self): """test getLineDiffs() method with dict same value""" c = C() diff = ListDiff(c, c, 'attribute') expected = [('equal', 0, 1, 0, 1)] self.assertEqual(diff.getLineDiffs(), expected)
def testSameText(self): """Test text diff output with no diff""" a = A() diff = ListDiff(a, a, 'attribute') expected = " 1\n 2\n 3" self.assertEqual(diff.ndiff(), expected)
def testAttributeSame(self): """Test attribute with same value""" a = A() diff = ListDiff(a, a, 'attribute') self.assertTrue(diff.same)
def testAttributeDiff(self): """Test attribute with different value""" a = A() b = B() diff = ListDiff(a, b, 'attribute') self.assertFalse(diff.same)
def testSameText(self): """Test text diff output with no diff""" a = A() diff = ListDiff(a, a, 'attribute') expected = ' 1%(linesep)s 2%(linesep)s 3' % {'linesep': linesep} self.assertEqual(diff.ndiff(), expected)
def testAttributeSame(self): """Test attribute with same value""" a = A() diff = ListDiff(a, a, 'attribute') self.failUnless(diff.same)