Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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())
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
 def testAttributeDiff(self):
     """Test attribute with different value"""
     a = A()
     b = B()
     diff = ListDiff(a, b, 'attribute')
     self.assertFalse(diff.same)
Exemplo n.º 10
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     diff = ListDiff(a, a, 'attribute')
     self.assertTrue(diff.same)
Exemplo n.º 11
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)
Exemplo n.º 12
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)
Exemplo n.º 13
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)
Exemplo n.º 14
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     diff = ListDiff(a, a, 'attribute')
     self.failUnless(diff.same)