File: test_command_collision.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 (53 lines) | stat: -rw-r--r-- 961 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pytest

from cyclopts import CommandCollisionError


def test_command_collision(app):
    @app.command
    def foo():
        pass

    with pytest.raises(CommandCollisionError):

        @app.command
        def foo():  # noqa: F811
            pass

    with pytest.raises(CommandCollisionError):

        @app.command(name="foo")
        def bar():
            pass


def test_command_collision_meta(app):
    @app.command
    def foo():
        pass

    with pytest.raises(CommandCollisionError):

        @app.meta.command
        def foo():  # noqa: F811
            pass

    with pytest.raises(CommandCollisionError):

        @app.meta.command(name="foo")
        def bar():
            pass


def test_command_collision_default(app):
    """Cannot register multiple functions to default."""

    @app.default
    def foo():
        pass

    with pytest.raises(CommandCollisionError):

        @app.default
        def bar():
            pass