Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Changelog

### 3.6.14 - bugfix
### 3.6.14 - bugfixes

- Fixed `AttributeError` issue in `is_case_function` when an inspected symbol is a parametrized type hint
without `__name__`. Fixes [#287](https://github.com/smarie/python-pytest-cases/issues/287)
- Fixed issue with `get_all_cases`: default value for `cases` was wrong. Fixes [#290](https://github.com/smarie/python-pytest-cases/issues/290)

### 3.6.13 - bugfix
Expand Down
6 changes: 5 additions & 1 deletion src/pytest_cases/case_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,8 @@ def is_case_function(f, # type: Any
# a function generated by us. ignore this
return False
else:
return f.__name__.startswith(prefix) if check_prefix else True
try:
return f.__name__.startswith(prefix) if check_prefix else True
except:
# GH#287: safe fallback
return False
24 changes: 24 additions & 0 deletions tests/cases/issues/test_py35_issue_287.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from typing import Tuple

import pytest_cases


class Cases:
ClassVar1 = int # OK
ClassVar2 = int # OK
ClassVar3 = 1 # OK
ClassVar4 = float # OK

ClassVar5 = Tuple[int] # FAILS with AttributeError: __name__
# ClassVar6 = Tuple[float] # FAILS with AttributeError: __name__
# ClassVar7 = List[int] # FAILS with AttributeError: __name__
# ClassVar8 = Any # FAILS with AttributeError: __name__
# ClassVar9 = Dict[int, str] # FAILS with AttributeError: __name__

def case_b(self):
return 1


@pytest_cases.parametrize_with_cases("case", Cases)
def test_something(case) -> None:
pass