Some times while using pytest we may end up in situation where we would like to pass a class object for assertion.
In some of situations i have come across , i used the same principal for invoking custom functions inside a module.
Below example simplify the process of passing a parameter to a pytest. This object could have n number of properties a savior when you have more then 7 parameters passed to the pytest function.
The below test code will generate 10 tests and pass random values to the class object.
Later inside pytest the passed values will be asserted.
1 Create a test class
2. Create a list to hold random generated objects and set values of each property with a random values from a list.
3. Create a pytest with marker parametrize and pass the object list .
In some of situations i have come across , i used the same principal for invoking custom functions inside a module.
Below example simplify the process of passing a parameter to a pytest. This object could have n number of properties a savior when you have more then 7 parameters passed to the pytest function.
The below test code will generate 10 tests and pass random values to the class object.
Later inside pytest the passed values will be asserted.
1 Create a test class
2. Create a list to hold random generated objects and set values of each property with a random values from a list.
3. Create a pytest with marker parametrize and pass the object list .