First of all, my English is poor and I'm new here. I'm sorry if I do something wrong.
My question is if I have multiple parameters, but I only want call setup_method once for every test_function.
However, it call setup every parameters (test case). I don't know how to solve this problem.
Here is my code:
class Test_Class:
def setup_method(self):
print("==========set up===========")
@pytest.mark.parametrize('people', ['Mike','Alice','Bob'])
@pytest.mark.parametrize('say', ['Hi','how is going on'])
def test_function(self, people, say):
print(people, say)
Here is the result
==========set up===========
Mike Hi
==========set up===========
Alice Hi
==========set up===========
Bob Hi
==========set up===========
Mike how is going on
==========set up===========
Alice how is going on
==========set up===========
Bob how is going on
But I want the result like this:
==========set up===========
Mike Hi
Alice Hi
Bob Hi
==========set up===========
Mike how is going on
Alice how is going on
Bob how is going on
The setup function is called with the next parameter.
Any suggestions will be greatly helpful
Thanks