示例#1
0
 def testDiffText(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     expected = "- कामसूत्र%s+ 過労死" % linesep
     fd = TextDiff(a, b, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
示例#2
0
 def testGetLineDiffsDifferent(self):
     """test getLineDiffs() method with different value"""
     a = A()
     b = B()
     fd = TextDiff(a, b, 'attribute')
     expected = [('replace', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
示例#3
0
    def testUnifiedDiff(self):
        """Test text diff output with different value"""
        a = A()
        b = B()

        expected = """--- version1

+++ version2

@@ -1 +1 @@

-कामसूत्र
+過労死"""
        fd = TextDiff(a, b, 'attribute', 'version1', 'version2')
        self.assertEqual(fd.unified_diff(), expected)
示例#4
0
 def testHTMLDiff(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     expected = """
 <table class="diff" id="difflib_chg_to0__top"
        cellspacing="0" cellpadding="0" rules="groups" >
     <colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup>
     <colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup>
     <thead><tr><th class="diff_next"><br /></th><th colspan="2" class="diff_header">None</th><th class="diff_next"><br /></th><th colspan="2" class="diff_header">None</th></tr></thead>
     <tbody>
         <tr><td class="diff_next" id="difflib_chg_to0__0"><a href="#difflib_chg_to0__top">t</a></td><td class="diff_header" id="from0_1">1</td><td nowrap="nowrap"><span class="diff_sub">कामसूत्र</span></td><td class="diff_next"><a href="#difflib_chg_to0__top">t</a></td><td class="diff_header" id="to0_1">1</td><td nowrap="nowrap"><span class="diff_add">過労死</span></td></tr>
     </tbody>
 </table>"""
     fd = TextDiff(a, b, 'attribute')
     self.assertEqual(fd.html_diff(), expected)
示例#5
0
    def testUnifiedDiff(self):
        """Test text diff output with different value"""
        a = A()
        b = B()
        if sys.version_info[:2] >= (2, 7):
            expected = """--- None

+++ None

@@ -1 +1 @@

-कामसूत्र
+過労死"""
        else:
            expected = """--- None 

+++ None 

@@ -1,1 +1,1 @@

-कामसूत्र
+過労死"""
        fd = TextDiff(a, b, 'attribute')
        self.assertEqual(fd.unified_diff(), expected)
示例#6
0
 def testSameText(self):
     """Test text diff output with same value"""
     a = A()
     fd = TextDiff(a, a, 'attribute')
     self.assertEqual(fd.ndiff(), '  कामसूत्र')
示例#7
0
 def testGetLineDiffsSame(self):
     """test getLineDiffs() method with same value"""
     a = A()
     fd = TextDiff(a, a, 'attribute')
     expected = [('equal', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
示例#8
0
 def testMethodDiff(self):
     """Test method with different value"""
     a = A()
     b = B()
     fd = TextDiff(a, b, 'method')
     self.failIf(fd.same)
示例#9
0
 def testAttributeDiff(self):
     """Test attribute with different value"""
     a = A()
     b = B()
     fd = TextDiff(a, b, 'attribute')
     self.failIf(fd.same)
示例#10
0
 def testMethodSame(self):
     """Test method with same value"""
     a = A()
     fd = TextDiff(a, a, 'method')
     self.failUnless(fd.same)
示例#11
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     fd = TextDiff(a, a, 'attribute')
     self.failUnless(fd.same)
示例#12
0
 def testMethodSame(self):
     """Test method with same value"""
     a = A()
     fd = TextDiff(a, a, 'method')
     self.assertTrue(fd.same)
示例#13
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     fd = TextDiff(a, a, 'attribute')
     self.assertTrue(fd.same)