[PATCH 3 of 5 pure-fix] tests: update more of test-bdiff.py to use unittest (part 3 of 4)

Augie Fackler raf at durin42.com
Thu Dec 15 11:32:35 EST 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1481817386 18000
#      Thu Dec 15 10:56:26 2016 -0500
# Node ID 3ec7ac3ed6743453db65e76147b4c296f6834a54
# Parent  609ce0f260cb7203f547abb770fb7efae08eb448
tests: update more of test-bdiff.py to use unittest (part 3 of 4)

diff --git a/tests/test-bdiff.py b/tests/test-bdiff.py
--- a/tests/test-bdiff.py
+++ b/tests/test-bdiff.py
@@ -93,6 +93,18 @@ class BdiffTests(unittest.TestCase):
         for old, new, want in cases:
             self.assertEqual(self.showdiff(old, new), want)
 
+    def test_fixws(self):
+        cases = [
+            (" \ta\r b\t\n", "ab\n", 1),
+            (" \ta\r b\t\n", " a b\n", 0),
+            ("", "", 1),
+            ("", "", 0),
+        ]
+        for a, b, allws in cases:
+            c = bdiff.fixws(a, allws)
+            self.assertEqual(
+                c, b, 'fixws(%r) want %r got %r (allws=%r)' % (a, b, c, allws))
+
 def showdiff(a, b):
     print('showdiff(\n  %r,\n  %r):' % (a, b))
     bin = bdiff.bdiff(a, b)
@@ -109,20 +121,6 @@ def showdiff(a, b):
     if q < len(a):
         print('', repr(a[q:]))
 
-def testfixws(a, b, allws):
-    c = bdiff.fixws(a, allws)
-    if c != b:
-        print("*** fixws", repr(a), repr(b), allws)
-        print("got:")
-        print(repr(c))
-
-testfixws(" \ta\r b\t\n", "ab\n", 1)
-testfixws(" \ta\r b\t\n", " a b\n", 0)
-testfixws("", "", 1)
-testfixws("", "", 0)
-
-print("done")
-
 print("Nice diff for a trivial change:")
 showdiff(
     ''.join('<%s\n-\n' % i for i in range(5)),
diff --git a/tests/test-bdiff.py.out b/tests/test-bdiff.py.out
--- a/tests/test-bdiff.py.out
+++ b/tests/test-bdiff.py.out
@@ -1,4 +1,3 @@
-done
 Nice diff for a trivial change:
 showdiff(
   '<0\n-\n<1\n-\n<2\n-\n<3\n-\n<4\n-\n',


More information about the Mercurial-devel mailing list