Skip to content

Commit 94c9741

Browse files
author
Sylvain MARIE
committed
Merge branch 'main' of https://github.com/smarie/python-pytest-cases into main
2 parents 8bb5378 + 976f4a8 commit 94c9741

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 3.6.10 - bugfix for pytest 7.1
4+
5+
- Fixed `ImportError` when using `pytest 7.1`. Fixed [#264](https://github.com/smarie/python-pytest-cases/issues/264) and [pytest-dev#9762](https://github.com/pytest-dev/pytest/issues/9762).
6+
37
### 3.6.9 - Bugfix with pytest 7
48

59
- Fixed `FrozenInstanceError` when using `pytest 7.0.0`. Fixed [#251](https://github.com/smarie/python-pytest-cases/issues/251). [PR#253](https://github.com/smarie/python-pytest-cases/pull/253) by [jammer87](https://github.com/jammer87)

src/pytest_cases/common_pytest.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from .common_others import get_function_host
3131
from .common_pytest_marks import make_marked_parameter_value, get_param_argnames_as_list, \
3232
get_pytest_parametrize_marks, get_pytest_usefixture_marks, PYTEST3_OR_GREATER, PYTEST6_OR_GREATER, \
33-
PYTEST38_OR_GREATER, PYTEST34_OR_GREATER, PYTEST33_OR_GREATER, PYTEST32_OR_GREATER
33+
PYTEST38_OR_GREATER, PYTEST34_OR_GREATER, PYTEST33_OR_GREATER, PYTEST32_OR_GREATER, PYTEST71_OR_GREATER
3434
from .common_pytest_lazy_values import is_lazy_value, is_lazy
3535

3636

@@ -554,22 +554,28 @@ def set_callspec_arg_scope_to_function(callspec, arg_name):
554554
callspec._arg2scopenum[arg_name] = get_pytest_function_scopeval() # noqa
555555

556556

557-
from _pytest.python import _idval # noqa
557+
if PYTEST71_OR_GREATER:
558+
from _pytest.python import IdMaker # noqa
558559

559-
if PYTEST6_OR_GREATER:
560-
_idval_kwargs = dict(idfn=None,
561-
nodeid=None, # item is not used in pytest(>=6.0.0) nodeid is only used by idfn
562-
config=None # if a config hook was available it would be used before this is called)
563-
)
564-
elif PYTEST38_OR_GREATER:
565-
_idval_kwargs = dict(idfn=None,
566-
item=None, # item is only used by idfn
567-
config=None # if a config hook was available it would be used before this is called)
568-
)
560+
_idval = IdMaker([], [], None, None, None, None, None)._idval
561+
_idval_kwargs = dict()
569562
else:
570-
_idval_kwargs = dict(idfn=None,
571-
# config=None # if a config hook was available it would be used before this is called)
572-
)
563+
from _pytest.python import _idval # noqa
564+
565+
if PYTEST6_OR_GREATER:
566+
_idval_kwargs = dict(idfn=None,
567+
nodeid=None, # item is not used in pytest(>=6.0.0) nodeid is only used by idfn
568+
config=None # if a config hook was available it would be used before this is called)
569+
)
570+
elif PYTEST38_OR_GREATER:
571+
_idval_kwargs = dict(idfn=None,
572+
item=None, # item is only used by idfn
573+
config=None # if a config hook was available it would be used before this is called)
574+
)
575+
else:
576+
_idval_kwargs = dict(idfn=None,
577+
# config=None # if a config hook was available it would be used before this is called)
578+
)
573579

574580

575581
def mini_idval(

src/pytest_cases/common_pytest_marks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
PYTEST421_OR_GREATER = PYTEST_VERSION >= LooseVersion('4.2.1')
4343
PYTEST6_OR_GREATER = PYTEST_VERSION >= LooseVersion('6.0.0')
4444
PYTEST7_OR_GREATER = PYTEST_VERSION >= LooseVersion('7.0.0')
45+
PYTEST71_OR_GREATER = PYTEST_VERSION >= LooseVersion('7.1.0')
4546

4647

4748
def get_param_argnames_as_list(argnames):
@@ -188,7 +189,7 @@ def remove_pytest_mark(f, mark_name):
188189
if marks is not None:
189190
# pytest > 3.2.0
190191
new_marks = [m for m in marks if m.name != mark_name]
191-
setattr(f, 'pytestmark', new_marks)
192+
f.pytestmark = new_marks
192193
else:
193194
# older versions
194195
try:

src/pytest_cases/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def get_all_fixture_defs(self, drop_fake_fixtures=True, try_to_sort=True):
191191
if PYTEST7_OR_GREATER:
192192
# Scope is an enum, values are in reversed order, and the field is _scope
193193
f_scope = get_pytest_function_scopeval()
194+
194195
def sort_by_scope(kv_pair):
195196
fixture_name, fixture_defs = kv_pair
196197
return fixture_defs[-1]._scope if fixture_defs is not None else f_scope

0 commit comments

Comments
 (0)