Skip to content

parametrize decorator does not work when placed above staticmethod #12863

@DetachHead

Description

@DetachHead
  • 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

Metadata

Metadata

Assignees

Labels

topic: collectionrelated to the collection phasetopic: marksrelated to marks, either the general marks or builtintopic: parametrizerelated to @pytest.mark.parametrizetopic: selectionrelated to test selection from the command linetype: bugproblem that needs to be addressed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions