summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-24 17:04:27 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-02-13 14:23:04 -0500
commite545298e35ea9f126054b337e4b5ba01988b29f7 (patch)
treee64aea159111d5921ff01f08b1c4efb667249dfe /test/base/test_utils.py
parentf1da1623b800cd4de3b71fd1b2ad5ccfde286780 (diff)
downloadsqlalchemy-e545298e35ea9f126054b337e4b5ba01988b29f7.tar.gz
establish mypy / typing approach for v2.0
large patch to get ORM / typing efforts started. this is to support adding new test cases to mypy, support dropping sqlalchemy2-stubs entirely from the test suite, validate major ORM typing reorganization to eliminate the need for the mypy plugin. * New declarative approach which uses annotation introspection, fixes: #7535 * Mapped[] is now at the base of all ORM constructs that find themselves in classes, to support direct typing without plugins * Mypy plugin updated for new typing structures * Mypy test suite broken out into "plugin" tests vs. "plain" tests, and enhanced to better support test structures where we assert that various objects are introspected by the type checker as we expect. as we go forward with typing, we will add new use cases to "plain" where we can assert that types are introspected as we expect. * For typing support, users will be much more exposed to the class names of things. Add these all to "sqlalchemy" import space. * Column(ForeignKey()) no longer needs to be `@declared_attr` if the FK refers to a remote table * composite() attributes mapped to a dataclass no longer need to implement a `__composite_values__()` method * with_variant() accepts multiple dialect names Change-Id: I22797c0be73a8fbbd2d6f5e0c0b7258b17fe145d Fixes: #7535 Fixes: #7551 References: #6810
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py44
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()