Issue #7092: Fix the DeprecationWarnings emitted by the standard library
when using the -3 flag. Patch by Florent Xicluna.
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 8da5743..2ebf2da 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -746,9 +746,15 @@
# not hashable.
expected = list(expected_seq)
actual = list(actual_seq)
- expected.sort()
- actual.sort()
- missing, unexpected = util.sorted_list_difference(expected, actual)
+ with warnings.catch_warnings():
+ if sys.py3kwarning:
+ # Silence Py3k warning
+ warnings.filterwarnings("ignore",
+ "dict inequality comparisons "
+ "not supported", DeprecationWarning)
+ expected.sort()
+ actual.sort()
+ missing, unexpected = util.sorted_list_difference(expected, actual)
errors = []
if missing:
errors.append('Expected, but missing:\n %r' % missing)