-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consoliadte Enum case test, close #570
- Loading branch information
Showing
2 changed files
with
26 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
""" | ||
Regresion test for | ||
Enum values that differ in case get conflated #570 | ||
https://github.com/tiangolo/typer/discussions/570 | ||
""" | ||
from enum import Enum | ||
|
||
import pytest | ||
import typer | ||
from typer.testing import CliRunner | ||
|
||
from tests.assets import enum_case as mod | ||
|
||
runner = CliRunner() | ||
app = typer.Typer() | ||
|
||
|
||
class Case(str, Enum): | ||
UPPER = "CASE" | ||
TITLE = "Case" | ||
LOWER = "case" | ||
|
||
def __str__(self) -> str: | ||
return self.value | ||
|
||
|
||
@app.command() | ||
def enum_case(case: Case): | ||
print(case) | ||
|
||
|
||
@pytest.mark.parametrize("case", mod.Case) | ||
def test_enum_case(case: mod.Case): | ||
"""regresion test for https://github.com/tiangolo/typer/discussions/570""" | ||
result = runner.invoke(mod.app, [f"{case}"]) | ||
@pytest.mark.parametrize("case", Case) | ||
def test_enum_case(case: Case): | ||
result = runner.invoke(app, [f"{case}"]) | ||
assert result.exit_code == 0 | ||
assert case in result.output |