summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-12-18 20:00:04 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-12-18 20:00:04 (GMT)
commitaddc6f5a21d5d04c5bf895e8ea46f67de129d75c (patch)
treefee6fbaa3394114112383ed7dfc0cd0b37066f87 /Lib/unittest/case.py
parent63563cdf9d3afe0bdffaece7b92b0a56d2360397 (diff)
downloadcpython-addc6f5a21d5d04c5bf895e8ea46f67de129d75c.zip
cpython-addc6f5a21d5d04c5bf895e8ea46f67de129d75c.tar.gz
cpython-addc6f5a21d5d04c5bf895e8ea46f67de129d75c.tar.bz2
#10573: use actual/expected consistently in unittest methods. The order of the args of assertCountEqual is also changed.
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index d6e80e8..177a2fe 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -904,17 +904,17 @@ class TestCase(object):
standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
- def assertDictContainsSubset(self, expected, actual, msg=None):
- """Checks whether actual is a superset of expected."""
+ def assertDictContainsSubset(self, subset, dictionary, msg=None):
+ """Checks whether dictionary is a superset of subset."""
missing = []
mismatched = []
- for key, value in expected.items():
- if key not in actual:
+ for key, value in subset.items():
+ if key not in dictionary:
missing.append(key)
- elif value != actual[key]:
+ elif value != dictionary[key]:
mismatched.append('%s, expected: %s, actual: %s' %
(safe_repr(key), safe_repr(value),
- safe_repr(actual[key])))
+ safe_repr(dictionary[key])))
if not (missing or mismatched):
return
@@ -973,13 +973,13 @@ class TestCase(object):
self.fail(self._formatMessage(msg, standardMsg))
- def assertCountEqual(self, expected_seq, actual_seq, msg=None):
+ def assertCountEqual(self, actual_seq, expected_seq, msg=None):
"""An unordered sequence specific comparison. It asserts that
- expected_seq and actual_seq have the same element counts.
+ actual_seq and expected_seq have the same element counts.
Equivalent to::
- self.assertEqual(Counter(iter(expected_seq)),
- Counter(iter(actual_seq)))
+ self.assertEqual(Counter(iter(actual_seq)),
+ Counter(iter(expected_seq)))
Asserts that each element has the same count in both sequences.
Example:
@@ -987,15 +987,15 @@ class TestCase(object):
- [0, 0, 1] and [0, 1] compare unequal.
"""
try:
- expected = collections.Counter(iter(expected_seq))
actual = collections.Counter(iter(actual_seq))
+ expected = collections.Counter(iter(expected_seq))
except TypeError:
# Unsortable items (example: set(), complex(), ...)
- expected = list(expected_seq)
actual = list(actual_seq)
+ expected = list(expected_seq)
missing, unexpected = unorderable_list_difference(expected, actual)
else:
- if expected == actual:
+ if actual == expected:
return
missing = list(expected - actual)
unexpected = list(actual - expected)