From: Mike Bayer Date: Tue, 25 Jan 2022 16:01:25 +0000 (-0500) Subject: join to existing mark expr with "and" X-Git-Tag: rel_2_0_0b1~511 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a17cd6492ee6a9b54be49016ed2aac3f0bb00ef0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git join to existing mark expr with "and" ca48f461b2dcac2970829e4e0 considered an existing mark expression plus legacy tags to be an error condition; however these can be joined by "and" and will in our use case do the right thing. The github action scripts make use of legacy tags. We can change that also but I want to just make sure this combination works fully as well. Change-Id: Ifc506de3dd961c01d68d594ec2f5b2c9a0bbad31 --- diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 363a73eccf..6efeac5049 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -70,16 +70,16 @@ def pytest_addoption(parser): def pytest_configure(config): if plugin_base.exclude_tags or plugin_base.include_tags: - if config.option.markexpr: - raise ValueError( - "Can't combine explicit pytest marks with legacy options " - "such as --backend-only, --exclude-tags, etc. " - ) - config.option.markexpr = " and ".join( + new_expr = " and ".join( list(plugin_base.include_tags) + [f"not {tag}" for tag in plugin_base.exclude_tags] ) + if config.option.markexpr: + config.option.markexpr += f" and {new_expr}" + else: + config.option.markexpr = new_expr + if config.pluginmanager.hasplugin("xdist"): config.pluginmanager.register(XDistHooks())