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)
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)
def testUnifiedDiff(self): """Test text diff output with different value""" a = A() b = B() expected = """--- None +++ None @@ -1,1 +1,1 @@ -कामसूत्र +過労死""" fd = TextDiff(a, b, "attribute") self.assertEqual(fd.unified_diff(), expected)
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)
def _parseField(self, value, filename=None): """Use the field's raw value if available.""" if value is None: value = '' else: value = getattr(value, 'raw', value) return TextDiff._parseField(self, value, filename)
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)
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)
def testAttributeSame(self): """Test attribute with same value""" a = A() fd = TextDiff(a, a, 'attribute') self.assertTrue(fd.same)
def _parseField(self, value, filename=None): if value is None: value = '' return TextDiff._parseField(self, str(value), filename)
def testSameText(self): """Test text diff output with same value""" a = A() fd = TextDiff(a, a, "attribute") self.assertEqual(fd.ndiff(), " कामसूत्र")
def testAttributeSame(self): """Test attribute with same value""" a = A() fd = TextDiff(a, a, 'attribute') self.failUnless(fd.same)
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)
def testMethodSame(self): """Test method with same value""" a = A() fd = TextDiff(a, a, 'method') self.failUnless(fd.same)
def testMethodSame(self): """Test method with same value""" a = A() fd = TextDiff(a, a, 'method') self.assertTrue(fd.same)
def testSameText(self): """Test text diff output with same value""" a = A() fd = TextDiff(a, a, 'attribute') self.assertEqual(fd.ndiff(), ' कामसूत्र')
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)
def testMethodDiff(self): """Test method with different value""" a = A() b = B() fd = TextDiff(a, b, 'method') self.failIf(fd.same)
def testAttributeDiff(self): """Test attribute with different value""" a = A() b = B() fd = TextDiff(a, b, 'attribute') self.failIf(fd.same)