summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-09-26 06:38:36 (GMT)
committerGitHub <noreply@github.com>2018-09-26 06:38:36 (GMT)
commitd45a9613402b686f8afd3dd5b6acf8141f14d711 (patch)
treeec99aa32aba5b44f7200e409679dd547cca1b3d6 /Lib/test/test_builtin.py
parentdc335ae77dfc1fb6a500eb1cd0baf23fcda45434 (diff)
downloadcpython-d45a9613402b686f8afd3dd5b6acf8141f14d711.zip
cpython-d45a9613402b686f8afd3dd5b6acf8141f14d711.tar.gz
cpython-d45a9613402b686f8afd3dd5b6acf8141f14d711.tar.bz2
[3.6] bpo-34320: Fix dict(o) didn't copy order of dict subclass (GH-8624) (GH-9583)
When dict subclass overrides order (`__iter__()`, `keys()`, and `items()`), `dict(o)` should use it instead of dict ordering. https://bugs.python.org/issue34320 (cherry picked from commit 2aaf98c16ae3070378de523a173e29644037d8bd) Co-authored-by: INADA Naoki <methane@users.noreply.github.com> https://bugs.python.org/issue34320
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index e0dbe78..e885e6d 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1841,6 +1841,15 @@ class TestType(unittest.TestCase):
with self.assertRaises(TypeError):
type('A', (B,), {'__slots__': '__weakref__'})
+ def test_namespace_order(self):
+ # bpo-34320: namespace should preserve order
+ od = collections.OrderedDict([('a', 1), ('b', 2)])
+ od.move_to_end('a')
+ expected = list(od.items())
+
+ C = type('C', (), od)
+ self.assertEqual(list(C.__dict__.items())[:2], [('b', 2), ('a', 1)])
+
def load_tests(loader, tests, pattern):
from doctest import DocTestSuite