Skip to content

Commit

Permalink
consoliadte Enum case test, close #570
Browse files Browse the repository at this point in the history
  • Loading branch information
avaldebe committed Mar 21, 2023
1 parent a933d91 commit 43a56b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
25 changes: 0 additions & 25 deletions tests/assets/enum_case.py

This file was deleted.

32 changes: 26 additions & 6 deletions tests/test_enum_case.py
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

0 comments on commit 43a56b8

Please sign in to comment.