Path 1: 2 calls (0.25)

Context (2)

Option (2)

'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_cli.py' (2)

'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_cli.py' (2)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value
            

Path 2: 2 calls (0.25)

Context (2)

Option (2)

None (2)

None (2)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value
            

Path 3: 1 calls (0.12)

Context (1)

Option (1)

None (1)

BadParameter (1)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value
            

Path 4: 1 calls (0.12)

Context (1)

Option (1)

'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_cli.py' (1)

BadParameter (1)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value
            

Path 5: 1 calls (0.12)

Context (1)

Option (1)

'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_cli.py' (1)

BadParameter (1)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value
            

Path 6: 1 calls (0.12)

Context (1)

Option (1)

'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_cli.py' (1)

BadParameter (1)

1def _validate_key(ctx, param, value):
2    """The ``--key`` option must be specified when ``--cert`` is a file.
3    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
4    """
5    cert = ctx.params.get("cert")
6    is_adhoc = cert == "adhoc"
7
8    try:
9        import ssl
10    except ImportError:
11        is_context = False
12    else:
13        is_context = isinstance(cert, ssl.SSLContext)
14
15    if value is not None:
16        if is_adhoc:
17            raise click.BadParameter(
18                'When "--cert" is "adhoc", "--key" is not used.', ctx, param
19            )
20
21        if is_context:
22            raise click.BadParameter(
23                'When "--cert" is an SSLContext object, "--key is not used.', ctx, param
24            )
25
26        if not cert:
27            raise click.BadParameter('"--cert" must also be specified.', ctx, param)
28
29        ctx.params["cert"] = cert, value
30
31    else:
32        if cert and not (is_adhoc or is_context):
33            raise click.BadParameter('Required when using "--cert".', ctx, param)
34
35    return value