diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-09-26 03:59:00 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-09-26 03:59:00 (GMT) |
commit | 2aaf98c16ae3070378de523a173e29644037d8bd (patch) | |
tree | 78b0a34f1d41d23a8b66e607a30fedfd2eb2a352 /Lib/test/test_call.py | |
parent | d345bb4d9b6e16c681cd8a4e1fff94ecd6b0bb09 (diff) | |
download | cpython-2aaf98c16ae3070378de523a173e29644037d8bd.zip cpython-2aaf98c16ae3070378de523a173e29644037d8bd.tar.gz cpython-2aaf98c16ae3070378de523a173e29644037d8bd.tar.bz2 |
bpo-34320: Fix dict(o) didn't copy order of dict subclass (GH-8624)
When dict subclass overrides order (`__iter__()`, `keys()`, and `items()`), `dict(o)`
should use it instead of dict ordering.
https://bugs.python.org/issue34320
Diffstat (limited to 'Lib/test/test_call.py')
-rw-r--r-- | Lib/test/test_call.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index ec9697a..45b34e4 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -9,6 +9,23 @@ import struct import collections import itertools + +class FunctionCalls(unittest.TestCase): + + def test_kwargs_order(self): + # bpo-34320: **kwargs should preserve order of passed OrderedDict + od = collections.OrderedDict([('a', 1), ('b', 2)]) + od.move_to_end('a') + expected = list(od.items()) + + def fn(**kw): + return kw + + res = fn(**od) + self.assertIsInstance(res, dict) + self.assertEqual(list(res.items()), expected) + + # The test cases here cover several paths through the function calling # code. They depend on the METH_XXX flag that is used to define a C # function, which can't be verified from Python. If the METH_XXX decl |