diff options
author | Raymond Hettinger <python@rcn.com> | 2010-12-24 10:30:06 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-12-24 10:30:06 (GMT) |
commit | f954217458add5e23dff6996de9f022a8d9e3b54 (patch) | |
tree | 52c99102ae6f756c7cbf37939b07b9f14a8d6810 /Lib | |
parent | 1e7efdf2a0ce34f36aa3137788f434cf2ad5931a (diff) | |
download | cpython-f954217458add5e23dff6996de9f022a8d9e3b54.zip cpython-f954217458add5e23dff6996de9f022a8d9e3b54.tar.gz cpython-f954217458add5e23dff6996de9f022a8d9e3b54.tar.bz2 |
Add direct tests for the util functions.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/unittest/test/test_case.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index 027b37a..9a09dfa 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -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() |