From 7690fe6d04e021460349a050abe4fa232a73b78f Mon Sep 17 00:00:00 2001 From: jammer87 <71280324+jammer87@users.noreply.github.com> Date: Sun, 6 Feb 2022 00:11:56 -0600 Subject: [PATCH] workaround for CallSpec2 attributes being frozen --- src/pytest_cases/fixture_parametrize_plus.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pytest_cases/fixture_parametrize_plus.py b/src/pytest_cases/fixture_parametrize_plus.py index 43b0f0c7..09c37c78 100644 --- a/src/pytest_cases/fixture_parametrize_plus.py +++ b/src/pytest_cases/fixture_parametrize_plus.py @@ -550,14 +550,20 @@ def get_alternative_id(self): EMPTY_ID = "" +def _replace_list_contents(the_list, new_contents): + """Replaces the contents of a list""" + the_list.clear() + the_list.extend(new_contents) + + if has_pytest_param: def remove_empty_ids(callspec): # used by plugin.py to remove the EMPTY_ID from the callspecs - callspec._idlist = [c for c in callspec._idlist if not c.startswith(EMPTY_ID)] + _replace_list_contents(callspec._idlist, [c for c in callspec._idlist if not c.startswith(EMPTY_ID)]) else: def remove_empty_ids(callspec): # used by plugin.py to remove the EMPTY_ID from the callspecs - callspec._idlist = [c for c in callspec._idlist if not c.endswith(EMPTY_ID)] + _replace_list_contents(callspec._idlist, [c for c in callspec._idlist if not c.endswith(EMPTY_ID)]) # elif PYTEST421_OR_GREATER: