summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-12-02 23:43:44 +0100
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-07 15:46:21 -0500
commit93cc9d7e8bcde2feca1ab8e6808124c0d4aae8d4 (patch)
treeb6c3b57b4835c7e8d109ccc0aa28640b7f1dbbc4 /test/base/test_utils.py
parent87d58b6d8188ccff808b3207d5f9398bb9adf9b9 (diff)
downloadsqlalchemy-93cc9d7e8bcde2feca1ab8e6808124c0d4aae8d4.tar.gz
Replace ``OrderedDict`` with a normal ``dict`` in python 3.7+
References: #5735 Change-Id: I0a73f727fb6820d32eca590b1e8afbfe2872adb8
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py
index 876cb7a44..6d2bb60c9 100644
--- a/test/base/test_utils.py
+++ b/test/base/test_utils.py
@@ -131,6 +131,33 @@ class OrderedDictTest(fixtures.TestBase):
o3 = copy.copy(o)
eq_(list(o3.keys()), list(o.keys()))
+ def test_no_sort_legacy_dictionary(self):
+ d1 = {"c": 1, "b": 2, "a": 3}
+
+ if testing.requires.python37.enabled:
+ util.sort_dictionary(d1)
+ eq_(list(d1), ["a", "b", "c"])
+ else:
+ assert_raises(AttributeError, util.sort_dictionary, d1)
+
+ def test_sort_dictionary(self):
+ o = util.OrderedDict()
+
+ o["za"] = 1
+ o["az"] = 2
+ o["cc"] = 3
+
+ eq_(
+ list(o),
+ ["za", "az", "cc"],
+ )
+
+ util.sort_dictionary(o)
+ eq_(list(o), ["az", "cc", "za"])
+
+ util.sort_dictionary(o, lambda key: key[1])
+ eq_(list(o), ["za", "cc", "az"])
+
class OrderedSetTest(fixtures.TestBase):
def test_mutators_against_iter(self):