[Python] Override a pytest parameterized functions name

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    My parameters determine the name of my parameterized pytest. I will be using a some randomized params for these tests. In order for my reporting names in junit to not get messed up, I'd like to create a static name for each parameterized test.

    Is it possible?

    JUnit seems to have a parameter: Changing names of parameterized tests

    class TestMe:
    @pytest.mark.parametrize(
    ("testname", "op", "value"),
    [
    ("testA", "plus", "3"),
    ("testB", "minus", "1"),
    ]
    )
    def test_ops(self, testname, op, value):


    I tried overwriting request.node.name however I can only rename it during test execution.

    I'm almost positive I either need to write a plugin or a fixture. What do you think would be the best way to go about this?

    Continue reading...

Compartilhe esta Página