]> granicus.if.org Git - python/commitdiff
Add direct tests for the util functions.
authorRaymond Hettinger <python@rcn.com>
Fri, 24 Dec 2010 10:30:06 +0000 (10:30 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 24 Dec 2010 10:30:06 +0000 (10:30 +0000)
Lib/unittest/test/test_case.py

index 027b37ac987df267699a8a6e5992211d0218d772..9a09dfaff0617283ed8b55a1a9df606ffc404e7f 100644 (file)
@@ -672,7 +672,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
         else:
             self.fail('assertMultiLineEqual did not fail')
 
-    def testassertCountEqual(self):
+    def testAssertCountEqual(self):
         a = object()
         self.assertCountEqual([1, 2, 3], [3, 2, 1])
         self.assertCountEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
@@ -721,6 +721,18 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
         b = a[::-1]
         self.assertCountEqual(a, b)
 
+        # test utility functions supporting assertCountEqual()
+
+        diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))
+        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+        self.assertEqual(diffs, expected)
+
+        diffs = unittest.util._count_diff_all_purpose([[]], [])
+        self.assertEqual(diffs, [(1, 0, [])])
+
+        diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce'))
+        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+        self.assertEqual(diffs, expected)
 
     def testAssertSetEqual(self):
         set1 = set()