diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-02-13 20:37:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-02-13 20:37:12 +0000 |
commit | d6b3c82b0c329730bcaff42b4bb39dba83acb536 (patch) | |
tree | d6b7f744a35c8d89615eeb0504ee7a4193f95642 /test/base/test_utils.py | |
parent | 260ade78a70d51378de9e7b9456bfe6218859b6c (diff) | |
parent | e545298e35ea9f126054b337e4b5ba01988b29f7 (diff) | |
download | sqlalchemy-d6b3c82b0c329730bcaff42b4bb39dba83acb536.tar.gz |
Merge "establish mypy / typing approach for v2.0" into main
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index dc02c37cb..67fcc8870 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -31,6 +31,7 @@ from sqlalchemy.util import compat from sqlalchemy.util import get_callable_argspec from sqlalchemy.util import langhelpers from sqlalchemy.util import WeakSequence +from sqlalchemy.util._collections import merge_lists_w_ordering class WeakSequenceTest(fixtures.TestBase): @@ -66,6 +67,49 @@ class WeakSequenceTest(fixtures.TestBase): eq_(len(w._storage), 2) +class MergeListsWOrderingTest(fixtures.TestBase): + @testing.combinations( + ( + ["__tablename__", "id", "x", "created_at"], + ["id", "name", "data", "y", "created_at"], + ["__tablename__", "id", "name", "data", "y", "x", "created_at"], + ), + (["a", "b", "c", "d", "e", "f"], [], ["a", "b", "c", "d", "e", "f"]), + ([], ["a", "b", "c", "d", "e", "f"], ["a", "b", "c", "d", "e", "f"]), + ([], [], []), + (["a", "b", "c"], ["a", "b", "c"], ["a", "b", "c"]), + ( + ["a", "b", "c"], + ["a", "b", "c", "d", "e"], + ["a", "b", "c", "d", "e"], + ), + (["a", "b", "c", "d"], ["c", "d", "e"], ["a", "b", "c", "d", "e"]), + ( + ["a", "c", "e", "g"], + ["b", "d", "f", "g"], + ["a", "c", "e", "b", "d", "f", "g"], # no overlaps until "g" + ), + ( + ["a", "b", "e", "f", "g"], + ["b", "c", "d", "e"], + ["a", "b", "c", "d", "e", "f", "g"], + ), + ( + ["a", "b", "c", "e", "f"], + ["c", "d", "f", "g"], + ["a", "b", "c", "d", "e", "f", "g"], + ), + ( + ["c", "d", "f", "g"], + ["a", "b", "c", "e", "f"], + ["a", "b", "c", "e", "d", "f", "g"], + ), + argnames="a,b,expected", + ) + def test_merge_lists(self, a, b, expected): + eq_(merge_lists_w_ordering(a, b), expected) + + class OrderedDictTest(fixtures.TestBase): def test_odict(self): o = util.OrderedDict() |