File: test_parameter_allow_leading_hyphen.py

package info (click to toggle)
python-cyclopts 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (23 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from typing import Annotated

import pytest

from cyclopts import Parameter
from cyclopts.exceptions import UnknownOptionError


def test_allow_leading_hyphen_false(app):
    @app.default
    def foo(bar: Annotated[str, Parameter()]):
        pass

    with pytest.raises(UnknownOptionError):
        app("--buzz", exit_on_error=False, print_error=True)


def test_allow_leading_hyphen_true(app, assert_parse_args):
    @app.default
    def foo(bar: Annotated[str, Parameter(allow_leading_hyphen=True)]):
        pass

    assert_parse_args(foo, "--buzz", bar="--buzz")