|
31 | 31 | from .common_pytest_lazy_values import is_lazy_value, get_lazy_args |
32 | 32 | from .common_pytest import get_fixture_name, remove_duplicates, mini_idvalset, is_marked_parameter_value, \ |
33 | 33 | extract_parameterset_info, ParameterSet, cart_product_pytest, mini_idval, inject_host, \ |
34 | | - get_marked_parameter_values, resolve_ids, get_marked_parameter_id, get_marked_parameter_marks, is_fixture |
| 34 | + get_marked_parameter_values, resolve_ids, get_marked_parameter_id, get_marked_parameter_marks, is_fixture, \ |
| 35 | + safe_isinstance |
35 | 36 |
|
36 | 37 | from .fixture__creation import check_name_available, CHANGE, WARN |
37 | 38 | from .fixture_core1_unions import InvalidParamsList, NOT_USED, UnionFixtureAlternative, _make_fixture_union, \ |
@@ -788,11 +789,16 @@ def _make_ids(**args): |
788 | 789 | else: |
789 | 790 | # wrap the decorator to check if the test function has the parameters as arguments |
790 | 791 | def _apply(test_func): |
791 | | - s = signature(test_func) |
792 | | - for p in argnames: |
793 | | - if p not in s.parameters: |
794 | | - raise ValueError("parameter '%s' not found in test function signature '%s%s'" |
795 | | - "" % (p, test_func.__name__, s)) |
| 792 | + if not safe_isinstance(test_func, type): |
| 793 | + # a Function: raise a proper error message if improper use |
| 794 | + s = signature(test_func) |
| 795 | + for p in argnames: |
| 796 | + if p not in s.parameters: |
| 797 | + raise ValueError("parameter '%s' not found in test function signature '%s%s'" |
| 798 | + "" % (p, test_func.__name__, s)) |
| 799 | + else: |
| 800 | + # a Class: we cannot really perform any check. |
| 801 | + pass |
796 | 802 | return _decorator(test_func) |
797 | 803 |
|
798 | 804 | return _apply, False |
@@ -926,6 +932,11 @@ def parametrize_plus_decorate(test_func, fixtures_dest): |
926 | 932 | test_func_name = test_func.__name__ |
927 | 933 |
|
928 | 934 | # first check if the test function has the parameters as arguments |
| 935 | + if safe_isinstance(test_func, type): |
| 936 | + # a test class: not supported yet |
| 937 | + raise NotImplementedError("@parametrize can not be used to decorate a Test class when the argvalues " |
| 938 | + "contain at least one reference to a fixture.") |
| 939 | + |
929 | 940 | old_sig = signature(test_func) |
930 | 941 | for p in argnames: |
931 | 942 | if p not in old_sig.parameters: |
|
0 commit comments