'Create a script inside script that will handle pytest execution of a test

I have pytest test function that is parameterized to read objects from a JSON file.

The issue I am facing is that I have a JSON with an array of objects. For each object from JSON, I need to call the testing method. The testing method is a selenium script that is submitting a form.

So my JSON has for example 3 array objects. I have to run the test for each of them, insert some data, and create a global response JSON that includes some execution data.

For the moment I am using pytest with parameterized tests. This is not a good approach as I can not create a response file for each test. Also at the end, I need to write a method that will iterate response JSON and if any test fails, I need to rerun it and rewrite its particular response in the global response JSON file. In the end, I need to have a global response JSON file for each execution, it should be an array of responses.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source