Skip to content

Instantly share code, notes, and snippets.

@jezdez
Created September 6, 2019 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezdez/88f5e7c8608f2892d7dccc9778719238 to your computer and use it in GitHub Desktop.
Save jezdez/88f5e7c8608f2892d7dccc9778719238 to your computer and use it in GitHub Desktop.
Pytest plugin to disable some plugins
def pytest_addoption(parser):
parser.addoption(
"--lean",
action="store_true",
default=False,
help="Set if this is running in a CI environment.",
)
def pytest_configure(config):
"""Hook implementation that unregisters optional plugins if "--ci" is specified."""
lean = config.getoption("lean")
if not lean:
return
optional_plugins = ["_cov", "flake8", "isort"]
for optional_plugin in optional_plugins:
config.pluginmanager.unregister(name=optional_plugin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment