@victor I am little confused over the issue since you have said "`assertDictEqual()` "will be used by default to compare dictionaries in calls to assertEqual()" and "`maxDiff` doesn't apply to `assertEqual()` when comparing dictionaries" . Since assertDictEqual is used for assertEqual calls when they compare dictionaries I can see that maxDiff value is applied to the diffs. A script will be helpful here on the expected and actual output. The attached script I have used to check that the maxDiff value is applied.
$ ./python.exe ../backups/bpo34514.py
FFFF
======================================================================
FAIL: test_assert_dict_equal_large_diff (__main__.Test_TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "../backups/bpo34514.py", line 59, in test_assert_dict_equal_large_diff
self.assertDictEqual(original, expected)
AssertionError: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, [726 chars]: 99} != {101: 101, 102: 102, 103: 103, 104: 104, 10[942 chars] 199}
Diff is 3347 characters long. Set self.maxDiff to None to see it.
======================================================================
FAIL: test_assert_dict_equal_small_diff (__main__.Test_TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "../backups/bpo34514.py", line 31, in test_assert_dict_equal_small_diff
self.assertDictEqual(original, expected)
AssertionError: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} != {101: 101, 102: 102, 103: 103, 104: 104, 10[42 chars] 109}
- {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
+ {101: 101,
+ 102: 102,
+ 103: 103,
+ 104: 104,
+ 105: 105,
+ 106: 106,
+ 107: 107,
+ 108: 108,
+ 109: 109}
======================================================================
FAIL: test_assert_equal_large_diff (__main__.Test_TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "../backups/bpo34514.py", line 45, in test_assert_equal_large_diff
self.assertEqual(original, expected)
AssertionError: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, [726 chars]: 99} != {101: 101, 102: 102, 103: 103, 104: 104, 10[942 chars] 199}
Diff is 3347 characters long. Set self.maxDiff to None to see it.
======================================================================
FAIL: test_assert_equal_small_diff (__main__.Test_TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "../backups/bpo34514.py", line 17, in test_assert_equal_small_diff
self.assertEqual(original, expected)
AssertionError: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} != {101: 101, 102: 102, 103: 103, 104: 104, 10[42 chars] 109}
- {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
+ {101: 101,
+ 102: 102,
+ 103: 103,
+ 104: 104,
+ 105: 105,
+ 106: 106,
+ 107: 107,
+ 108: 108,
+ 109: 109}
----------------------------------------------------------------------
Ran 4 tests in 3.496s
FAILED (failures=4)
Thanks |