Allow using Click 7 with a DeprecationWarning

As long as popular libraries (e.g. Celery) require click 7, depending
on Click 8 in Flask makes it hard to test the latest version (and its
other dependencies) in existing applications.
This commit is contained in:
Adrian Moennich 2021-04-24 20:01:09 +02:00
parent 1a8549debb
commit 26a6cc0f94
5 changed files with 26 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import ssl
import sys
import types
from functools import partial
from unittest.mock import patch
import click
import pytest
@ -21,6 +22,7 @@ from flask.cli import FlaskGroup
from flask.cli import get_version
from flask.cli import load_dotenv
from flask.cli import locate_app
from flask.cli import main as cli_main
from flask.cli import NoAppException
from flask.cli import prepare_import
from flask.cli import run_command
@ -660,3 +662,11 @@ def test_cli_empty(app):
result = app.test_cli_runner().invoke(args=["blue", "--help"])
assert result.exit_code == 2, f"Unexpected success:\n\n{result.output}"
def test_click_7_deprecated():
with patch("flask.cli.cli"):
if int(click.__version__[0]) < 8:
pytest.deprecated_call(cli_main, match=".* Click 7 is deprecated")
else:
cli_main()