Пример #1
0
 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)
Пример #2
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #9
0
    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)
Пример #10
0
    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
Пример #12
0
    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
Пример #13
0
    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())
Пример #14
0
    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())
Пример #15
0
 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)
Пример #16
0
 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)
Пример #17
0
 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)
Пример #18
0
 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)
Пример #19
0
 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)
Пример #20
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     diff = ListDiff(a, a, 'attribute')
     self.assertTrue(diff.same)
Пример #21
0
 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)
Пример #22
0
 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)
Пример #23
0
 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)
Пример #24
0
 def testAttributeDiff(self):
     """Test attribute with different value"""
     a = A()
     b = B()
     diff = ListDiff(a, b, 'attribute')
     self.assertFalse(diff.same)
Пример #25
0
 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)
Пример #26
0
 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)
Пример #27
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     diff = ListDiff(a, a, 'attribute')
     self.failUnless(diff.same)