From 1ab483ac5481cb60e898f0bfdad54e5ca45bbb80 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 4 Dec 2019 19:18:57 -0500 Subject: Introduce lambda combinations As the ORM's combinatoric tests mostly use entities and table metadata that's defined in fixtures, we can't use @testing.combinations directly as it takes place at the module level. Instead we use lambdas, but to reduce verbosity we use a code replacement so that the namespace of the lambda can be provided at runtime rather than module import time. Change-Id: Ia63a510f9c1d08b055eef62cf047f1f427f0450c --- lib/sqlalchemy/testing/plugin/pytestplugin.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin/pytestplugin.py') diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 44fccf28d..3e0630890 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -363,6 +363,7 @@ class PytestFixtureFunctions(plugin_base.FixtureFunctions): for idx, char in enumerate(id_) if char in _combination_id_fns ] + arg_sets = [ pytest.param( *_arg_getter(_filter_exclusions(arg))[1:], @@ -370,14 +371,21 @@ class PytestFixtureFunctions(plugin_base.FixtureFunctions): comb_fn(getter(arg)) for getter, comb_fn in fns ) ) - for arg in arg_sets + for arg in [ + (arg,) if not isinstance(arg, tuple) else arg + for arg in arg_sets + ] ] else: # ensure using pytest.param so that even a 1-arg paramset # still needs to be a tuple. otherwise paramtrize tries to # interpret a single arg differently than tuple arg arg_sets = [ - pytest.param(*_filter_exclusions(arg)) for arg in arg_sets + pytest.param(*_filter_exclusions(arg)) + for arg in [ + (arg,) if not isinstance(arg, tuple) else arg + for arg in arg_sets + ] ] def decorate(fn): -- cgit v1.2.1