How to make integration test to wait run be over?

  integration-testing, pytest, python

I am writing an integration test using Pytest framework. Test passes when I run it using VS Code UI run under the test section, however it fails when running the test in terminal using script. I need to call which does the magic generates files, and I compare that files, and here is my sudo code for the workflow.
So running test in terminal does not even wait call(["Python", main_path, inputFilePath]) which call in another file to be over and jumps in to next line, and complaining about integration_test_output.json missing, if it wait like as VS code testing UI run this file will be generated.
 class IntegrationTest
   def call_main(test_folder_name:str):
     #Does some preparation before calling the main
      call(["Python", main_path, inputFilePath]) # call the main, main generates output csv files, and json files
   def test_something():
      #Some code runs here
      with open(integrationtestrunoutputfolderpath+"integration_test_output.json") as json_file:
        integration_test_output_dict = json.load(json_file)

Source: Python Questions