Skip to content

Test failures with click 8.3.1 #5836

@dotlambda

Description

@dotlambda

Click 8.3.1 was tagged but not released on PyPI. Running flask's test suite with that version results in

============================= test session starts ==============================
platform linux -- Python 3.13.8, pytest-8.4.2, pluggy-1.6.0
rootdir: /build/flask-3.1.2
configfile: pyproject.toml
testpaths: tests
collected 490 items                                                            

tests/test_appctx.py ..............                                      [  2%]
tests/test_async.py ........                                             [  4%]
tests/test_basic.py .................................................... [ 15%]
........................................................................ [ 29%]
......                                                                   [ 31%]
tests/test_blueprints.py ............................................... [ 40%]
.............                                                            [ 43%]
tests/test_cli.py ...................................................F.. [ 54%]
...F                                                                     [ 55%]
tests/test_config.py ...................                                 [ 58%]
tests/test_converters.py ..                                              [ 59%]
tests/test_helpers.py ...................................                [ 66%]
tests/test_instance_config.py .......                                    [ 67%]
tests/test_json.py ...............................                       [ 74%]
tests/test_json_tag.py ..............                                    [ 77%]
tests/test_logging.py ......                                             [ 78%]
tests/test_regression.py .                                               [ 78%]
tests/test_reqctx.py .......ss.....                                      [ 81%]
tests/test_request.py ...                                                [ 82%]
tests/test_session_interface.py .                                        [ 82%]
tests/test_signals.py .......                                            [ 83%]
tests/test_subclassing.py .                                              [ 83%]
tests/test_templating.py ................................                [ 90%]
tests/test_testing.py .........................                          [ 95%]
tests/test_user_error_handler.py .........                               [ 97%]
tests/test_views.py .............                                        [100%]

=================================== FAILURES ===================================
______________________________ test_run_cert_path ______________________________

    def test_run_cert_path():
        # no key
        with pytest.raises(click.BadParameter):
            run_command.make_context("run", ["--cert", __file__])
    
        # no cert
>       with pytest.raises(click.BadParameter):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       Failed: DID NOT RAISE <class 'click.exceptions.BadParameter'>


tests/test_cli.py:590: Failed
__________________________ test_run_exclude_patterns ___________________________

    def test_run_exclude_patterns():
>       ctx = run_command.make_context("run", ["--exclude-patterns", __file__])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


tests/test_cli.py:701: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/53y968aagcaaq46hq3rg2a3mmxwmzvm1-python3.13-click-8.3.1/lib/python3.13/site-packages/click/core.py:1216: in make_context
    self.parse_args(ctx, args)
        args       = []
        ctx        = <click.core.Context object at 0x7ffff4c02b10>
        extra      = {}
        info_name  = 'run'
        parent     = None
        self       = <Command run>
/nix/store/53y968aagcaaq46hq3rg2a3mmxwmzvm1-python3.13-click-8.3.1/lib/python3.13/site-packages/click/core.py:1227: in parse_args
    _, args = param.handle_parse_result(ctx, opts, args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        _          = 5000
        args       = []
        ctx        = <click.core.Context object at 0x7ffff4c02b10>
        opts       = {'exclude_patterns': '/build/flask-3.1.2/tests/test_cli.py'}
        param      = <Option key>
        param_order = [<Option exclude_patterns>]
        parser     = <click.parser._OptionParser object at 0x7ffff4b08bd0>
        self       = <Command run>
/nix/store/53y968aagcaaq46hq3rg2a3mmxwmzvm1-python3.13-click-8.3.1/lib/python3.13/site-packages/click/core.py:2548: in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        args       = []
        ctx        = <click.core.Context object at 0x7ffff4c02b10>
        opts       = {'exclude_patterns': '/build/flask-3.1.2/tests/test_cli.py'}
        self       = <Option key>
        source     = <ParameterSource.DEFAULT: 3>
        value      = Sentinel.UNSET
/nix/store/53y968aagcaaq46hq3rg2a3mmxwmzvm1-python3.13-click-8.3.1/lib/python3.13/site-packages/click/core.py:3283: in process_value
    return super().process_value(ctx, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        __class__  = <class 'click.core.Option'>
        ctx        = <click.core.Context object at 0x7ffff4c02b10>
        self       = <Option key>
        value      = Sentinel.UNSET
/nix/store/53y968aagcaaq46hq3rg2a3mmxwmzvm1-python3.13-click-8.3.1/lib/python3.13/site-packages/click/core.py:2443: in process_value
    value = self.callback(ctx, self, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ctx        = <click.core.Context object at 0x7ffff4c02b10>
        self       = <Option key>
        value      = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ctx = <click.core.Context object at 0x7ffff4c02b10>, param = <Option key>
value = None

    def _validate_key(ctx: click.Context, param: click.Parameter, value: t.Any) -> t.Any:
        """The ``--key`` option must be specified when ``--cert`` is a file.
        Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
        """
        cert = ctx.params.get("cert")
        is_adhoc = cert == "adhoc"
    
        try:
            import ssl
        except ImportError:
            is_context = False
        else:
            is_context = isinstance(cert, ssl.SSLContext)
    
        if value is not None:
            if is_adhoc:
                raise click.BadParameter(
                    'When "--cert" is "adhoc", "--key" is not used.', ctx, param
                )
    
            if is_context:
                raise click.BadParameter(
                    'When "--cert" is an SSLContext object, "--key" is not used.',
                    ctx,
                    param,
                )
    
            if not cert:
                raise click.BadParameter('"--cert" must also be specified.', ctx, param)
    
            ctx.params["cert"] = cert, value
    
        else:
            if cert and not (is_adhoc or is_context):
>               raise click.BadParameter('Required when using "--cert".', ctx, param)
E               click.exceptions.BadParameter: Required when using "--cert".

cert       = Sentinel.UNSET
ctx        = <click.core.Context object at 0x7ffff4c02b10>
is_adhoc   = False
is_context = False
param      = <Option key>
ssl        = <module 'ssl' from '/nix/store/cfapjd2rvqrpry4grb0kljnp8bvnvfxz-python3-3.13.8/lib/python3.13/ssl.py'>
value      = None

/nix/store/12gfdjrf93rixvjrkj9pbfy5349q3j4m-python3.13-flask-3.1.2/lib/python3.13/site-packages/flask/cli.py:870: BadParameter
=========================== short test summary info ============================
FAILED tests/test_cli.py::test_run_cert_path - Failed: DID NOT RAISE <class 'click.exceptions.BadParameter'>
FAILED tests/test_cli.py::test_run_exclude_patterns - click.exceptions.BadParameter: Required when using "--cert".
================== 2 failed, 486 passed, 2 skipped in 13.73s ===================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions