FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix parametrized mark over staticmethod decorator by eitanwass · Pull Request #13022 · pytest-dev/pytest · GitHub

Fix parametrized mark over staticmethod decorator - #13022

Merged
bluetech merged 5 commits into
pytest-dev:mainfrom
eitanwass:bugfix/parametrize-over-staticmethod
Dec 14, 2024
Merged

Fix parametrized mark over staticmethod decorator#13022
bluetech merged 5 commits into
pytest-dev:mainfrom
eitanwass:bugfix/parametrize-over-staticmethod

Conversation

eitanwass commented Dec 2, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

Fixed parametrized markers over staticmethod and classmethod decorators.
closes #12863

An interesting thing about this solution and python (<3.9 vs 3.10<) compatibility:
In python3.10, they changed @staticmethod and @classmethod decorators to inherit method attributes.
Before that version, functions wrapped with them did not return true for callable() func, so it failed tests for py39 and succeeded for py310.
link to changelog

For example:

from pytest import mark

class TestA:
    @mark.parametrize("value", [1, 2])
    @staticmethod
    def test_foo(value: int):
        """Didn't work. Now fixed :)"""

    @pytest.mark.parametrize("value", [1, 2])
    @classmethod
    def test_bar(cls, value: int):
        """Didn't work. Now fixed :)"""

    @staticmethod
    @mark.parametrize("value", [1, 2])
    def test_baz(value: int):
        """Works"""

psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Dec 2, 2024
eitanwass marked this pull request as draft December 2, 2024 21:01
eitanwass marked this pull request as ready for review December 4, 2024 18:16

bluetech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for tackling this @eitanwass! I left a couple of suggestions/questions.

Comment thread changelog/12863.bugfix.rst Outdated
Comment thread testing/test_mark.py Outdated
Comment thread testing/test_mark.py Outdated
Comment thread testing/test_mark.py
eitanwass requested a review from bluetech December 5, 2024 17:45
Comment thread changelog/12863.bugfix.rst Outdated
Comment thread testing/test_mark.py Outdated
eitanwass requested a review from bluetech December 6, 2024 07:17

bluetech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

bluetech merged commit 6dd3fff into pytest-dev:main Dec 14, 2024

Copy link
Copy Markdown
Member

Hmph, should have squashed...

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parametrize decorator does not work when placed above staticmethod

2 participants


Back | FazBrowse Home | New Git URL