changeset 30598:4286015285ec

tests: update more of test-bdiff.py to use unittest (part 3 of 4)
author Augie Fackler <augie@google.com>
date Thu, 15 Dec 2016 10:56:26 -0500
parents 0d8cada9998d
children ea648e8f8a34
files tests/test-bdiff.py tests/test-bdiff.py.out
diffstat 2 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-bdiff.py	Thu Dec 15 10:50:06 2016 -0500
+++ b/tests/test-bdiff.py	Thu Dec 15 10:56:26 2016 -0500
@@ -94,6 +94,18 @@
         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)
@@ -110,20 +122,6 @@
     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)),
--- a/tests/test-bdiff.py.out	Thu Dec 15 10:50:06 2016 -0500
+++ b/tests/test-bdiff.py.out	Thu Dec 15 10:56:26 2016 -0500
@@ -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',