59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
import click
|
|
import yaml
|
|
|
|
import dbyaml.cli
|
|
from dbyaml.cli import pass_context, uses_decorator # ty: ignore[unresolved-import]
|
|
|
|
|
|
def test_uses_decorator_cli():
|
|
assert uses_decorator("main", "pass_context", dbyaml.cli.__file__)
|
|
assert uses_decorator("list", "pass_context", dbyaml.cli.__file__)
|
|
|
|
|
|
def test_uses_decorator_wo():
|
|
@click.command
|
|
@pass_context
|
|
def cli_wo(ctx): ...
|
|
|
|
assert uses_decorator("cli_wo", "pass_context", __file__)
|
|
|
|
|
|
def test_uses_decorator_wo_long():
|
|
@click.command
|
|
@dbyaml.cli.pass_context # ty: ignore[unresolved-attribute]
|
|
def cli_wh_long(ctx): ...
|
|
|
|
assert dbyaml.cli.uses_decorator("cli_wh_long", "pass_context", __file__) # ty: ignore[unresolved-attribute]
|
|
|
|
|
|
def test_uses_decorator_call():
|
|
@click.command
|
|
@pass_context()
|
|
def cli_call(ctx): ...
|
|
|
|
assert uses_decorator("cli_call", "pass_context()", __file__)
|
|
|
|
|
|
def test_uses_decorator_obj():
|
|
@click.command
|
|
@pass_context(False)
|
|
def cli_obj(ctx): ...
|
|
|
|
assert uses_decorator("cli_obj", "pass_context()", __file__)
|
|
|
|
|
|
def test_uses_decorator_mod():
|
|
@click.command
|
|
@pass_context(yaml)
|
|
def cli_mod(ctx): ...
|
|
|
|
assert uses_decorator("cli_mod", "pass_context()", __file__)
|
|
|
|
|
|
def test_uses_decorator_func():
|
|
@click.command
|
|
@pass_context(yaml.dump)
|
|
def cli_func(ctx): ...
|
|
|
|
assert uses_decorator("cli_func", "pass_context()", __file__)
|