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

parametrize decorator does not work when placed above staticmethod #12863

Open
3 of 4 tasks
DetachHead opened this issue Oct 8, 2024 · 1 comment
Open
3 of 4 tasks
Assignees
Labels
topic: collection related to the collection phase topic: marks related to marks, either the general marks or builtin topic: parametrize related to @pytest.mark.parametrize topic: selection related to test selection from the command line type: bug problem that needs to be addressed

Comments

@DetachHead
Copy link
Contributor

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using (not using pip)
  • pytest and operating system versions
  • minimal example if possible
from pytest import mark

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

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

output of pytest --collect-only:

      <Module test_foo.py>
        <Class TestA>
          <Function test_foo>
          <Function test_bar[1]>
          <Function test_bar[2]>

pytest 8.3.3

it should ideally work for both, but if that's not feasible it should at least raise an exception saying that the decorators are in the wrong order

@RonnyPfannschmidt RonnyPfannschmidt added type: bug problem that needs to be addressed topic: parametrize related to @pytest.mark.parametrize topic: collection related to the collection phase topic: selection related to test selection from the command line topic: marks related to marks, either the general marks or builtin labels Oct 8, 2024
@mikeleppane
Copy link

Hey! I would be interested in taking a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase topic: marks related to marks, either the general marks or builtin topic: parametrize related to @pytest.mark.parametrize topic: selection related to test selection from the command line type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants