summaryrefslogtreecommitdiff
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 993aaec194..f19afef48d 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -338,6 +338,16 @@ class _AssertLogsContext(_BaseTestCaseContext):
.format(logging.getLevelName(self.level), self.logger.name))
+class _OrderedChainMap(collections.ChainMap):
+ def __iter__(self):
+ seen = set()
+ for mapping in self.maps:
+ for k in mapping:
+ if k not in seen:
+ seen.add(k)
+ yield k
+
+
class TestCase(object):
"""A class whose instances are single test cases.
@@ -514,7 +524,7 @@ class TestCase(object):
return
parent = self._subtest
if parent is None:
- params_map = collections.ChainMap(params)
+ params_map = _OrderedChainMap(params)
else:
params_map = parent.params.new_child(params)
self._subtest = _SubTest(self, msg, params_map)
@@ -1418,7 +1428,7 @@ class _SubTest(TestCase):
if self.params:
params_desc = ', '.join(
"{}={!r}".format(k, v)
- for (k, v) in sorted(self.params.items()))
+ for (k, v) in self.params.items())
parts.append("({})".format(params_desc))
return " ".join(parts) or '(<subtest>)'