Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for CallSpec2 attributes being frozen #253

Closed
wants to merge 1 commit into from

Conversation

jammer87
Copy link
Contributor

@jammer87 jammer87 commented Feb 6, 2022

Fixes #251

In pytest 7, CallSpec2 was refactored and it made attributes read-only causing the issue from #251.

before this change, running pytest on the example from #251:

plugins: cases-3.6.8
collected 0 items / 1 error

=================================================================== ERRORS ===================================================================
__________________________________________________ ERROR collecting tests/issue_221_test.py __________________________________________________
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pluggy\_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pluggy\_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\_pytest\python.py:257: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\_pytest\python.py:487: in _genfunctions
    fixtures.add_funcarg_pseudo_fixture_def(self, metafunc, fm)
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\_pytest\fixtures.py:164: in add_funcarg_pseudo_fixture_def
    if not metafunc._calls[0].funcargs:
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pytest_cases\plugin.py:931: in __getitem__
    return self.calls_list[item]
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pytest_cases\plugin.py:942: in calls_list
    self.create_call_list_from_pending_parametrizations()
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pytest_cases\plugin.py:994: in create_call_list_from_pending_parametrizations
    remove_empty_ids(callspec)
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\pytest_cases\fixture_parametrize_plus.py:560: in remove_empty_ids
    callspec._idlist = [c for c in callspec._idlist if not c.startswith(EMPTY_ID)]
..\.virtualenvs\pytest-cases-test-aSbyvtak\lib\site-packages\attr\_make.py:642: in _frozen_setattrs
    raise FrozenInstanceError()
E   attr.exceptions.FrozenInstanceError
========================================================== short test summary info ===========================================================
ERROR tests/issue_221_test.py - attr.exceptions.FrozenInstanceError
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================== 1 error in 0.52s ==============================================================

With this change:

plugins: cases-3.6.8
collected 2 items

tests\issue_221_test.py ..                                                                                                              [100%]

============================================================= 2 passed in 0.05s ==============================================================

@saroad2
Copy link
Contributor

saroad2 commented Feb 7, 2022

This is a very needed PR!
One cannot use pytest 7.0 without it.

@smarie , can you publish a new pytest-cases version after merging this PR?

@smarie
Copy link
Owner

smarie commented Feb 8, 2022

Thanks so much @jammer87 for this ! I'll check that PR builds ok and merge+release asap

@jammer87
Copy link
Contributor Author

jammer87 commented Feb 8, 2022

@smarie Besides the 2.7 failures for list not having the clear method, at first glance I'm not sure what's going wrong in the tests. Can you take over from here? You might also want to add pytest 6 checks as well now that the latest is 7.

@smarie
Copy link
Owner

smarie commented Feb 8, 2022

Yes, I'll take over.

smarie pushed a commit that referenced this pull request Feb 8, 2022
@smarie smarie mentioned this pull request Feb 8, 2022
smarie added a commit that referenced this pull request Feb 8, 2022
* workaround for CallSpec2 attributes being frozen

* Taking over work from #253 : fixed python 2 builds and added builds for pytest 6 in nox file

* Fixed test with pytest 7

* Removed test config with pytest asyncio pytest 5.x and python 3.8. It seems to be causing issues in gh actions.

* Removed test config with pytest asyncio pytest 5.x and python 3.7. It seems to be causing issues in gh actions.

Co-authored-by: jammer87 <71280324+jammer87@users.noreply.github.com>
Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
@smarie
Copy link
Owner

smarie commented Feb 8, 2022

Merged through #255

A huge thanks to you @jammer87 !

@smarie smarie closed this Feb 8, 2022
@smarie
Copy link
Owner

smarie commented Feb 8, 2022

Note: I thought that this would be marked as "merged" because I actually merged it in the branch that I used for the other PR #255. Strange that github did not realize it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for pytest 7.0.0?
3 participants