summaryrefslogtreecommitdiff
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-07 12:14:25 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-07 12:14:25 +0000
commit1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07 (patch)
tree42dc10540da9b1aff1d4e6cef51e4c11ce4f5b47 /Lib/unittest/case.py
parent2a4ab816332a67150fcc8ece255fb1ee8e66af83 (diff)
downloadcpython-git-1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07.tar.gz
Fix some py3k warnings in the standard library.
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 88d1bec889..aacd67ca08 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -774,26 +774,23 @@ class TestCase(object):
set(actual))`` but it works with sequences of unhashable objects as
well.
"""
- try:
- expected = set(expected_seq)
- actual = set(actual_seq)
- missing = list(expected.difference(actual))
- unexpected = list(actual.difference(expected))
- missing.sort()
- unexpected.sort()
- except TypeError:
- # Fall back to slower list-compare if any of the objects are
- # not hashable.
- expected = list(expected_seq)
- actual = list(actual_seq)
- with warnings.catch_warnings():
- if sys.py3kwarning:
- # Silence Py3k warning
- warnings.filterwarnings("ignore",
- "dict inequality comparisons "
- "not supported", DeprecationWarning)
- expected.sort()
- actual.sort()
+ with warnings.catch_warnings():
+ if sys.py3kwarning:
+ # Silence Py3k warning raised during the sorting
+ for msg in ["dict inequality comparisons",
+ "builtin_function_or_method order comparisons",
+ "comparing unequal types"]:
+ warnings.filterwarnings("ignore", msg, DeprecationWarning)
+ try:
+ expected = set(expected_seq)
+ actual = set(actual_seq)
+ missing = sorted(expected.difference(actual))
+ unexpected = sorted(actual.difference(expected))
+ except TypeError:
+ # Fall back to slower list-compare if any of the objects are
+ # not hashable.
+ expected = sorted(expected_seq)
+ actual = sorted(actual_seq)
missing, unexpected = sorted_list_difference(expected, actual)
errors = []
if missing: