Skip to content

Commit 03f6813

Browse files
author
Sylvain MARIE
committed
Empty case ids are now replaced with '<<empty_case_id>' to avoid ambiguous interpretation of test ids. Fixes #142
1 parent 1d33f2f commit 03f6813

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pytest_cases/case_funcs_new.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def get_from(cls, case_func, create=False, prefix_for_ids='case_'):
6767
case_info.id = case_func.__name__[len(prefix_for_ids):]
6868
else:
6969
case_info.id = case_func.__name__
70+
# default case id for empty id
71+
if len(case_info.id) == 0:
72+
case_info.id = "<empty_case_id>"
7073

7174
return case_info
7275

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
from pytest_cases import parametrize_with_cases
4+
5+
6+
@pytest.mark.parametrize('dummy_amount', [1, 0, -1])
7+
def case_amount(dummy_amount):
8+
return dummy_amount
9+
10+
11+
@parametrize_with_cases('dummy_amount', cases=".", prefix="case_amount")
12+
def test_empty_prefix(dummy_amount):
13+
pass
14+
15+
16+
def test_synthesis(module_results_dct):
17+
assert list(module_results_dct) == [
18+
'test_empty_prefix[<empty_case_id>-1]',
19+
'test_empty_prefix[<empty_case_id>-0]',
20+
'test_empty_prefix[<empty_case_id>--1]'
21+
]

0 commit comments

Comments
 (0)