| 1 |
import pytest |
| 2 |
|
| 3 |
from cyclopts import CommandCollisionError |
| 4 |
|
| 5 |
|
| 6 |
def test_command_collision(app): |
| 7 |
@app.command |
| 8 |
def foo(): |
| 9 |
pass |
| 10 |
|
| 11 |
with pytest.raises(CommandCollisionError): |
| 12 |
|
| 13 |
@app.command |
| 14 |
def foo(): |
| 15 |
pass |
| 16 |
|
| 17 |
with pytest.raises(CommandCollisionError): |
| 18 |
|
| 19 |
@app.command(name="foo") |
| 20 |
def bar(): |
| 21 |
pass |
| 22 |
|
| 23 |
|
| 24 |
def test_command_collision_meta(app): |
| 25 |
@app.command |
| 26 |
def foo(): |
| 27 |
pass |
| 28 |
|
| 29 |
with pytest.raises(CommandCollisionError): |
| 30 |
|
| 31 |
@app.meta.command |
| 32 |
def foo(): |
| 33 |
pass |
| 34 |
|
| 35 |
with pytest.raises(CommandCollisionError): |
| 36 |
|
| 37 |
@app.meta.command(name="foo") |
| 38 |
def bar(): |
| 39 |
pass |
| 40 |
|
| 41 |
|
| 42 |
def test_command_collision_default(app): |
| 43 |
"""Cannot register multiple functions to default.""" |
| 44 |
|
| 45 |
@app.default |
| 46 |
def foo(): |
| 47 |
pass |
| 48 |
|
| 49 |
with pytest.raises(CommandCollisionError): |
| 50 |
|
| 51 |
@app.default |
| 52 |
def bar(): |
| 53 |
pass |