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 main.py 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 main.py 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.
integration_test.py 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(): #arrange #Some code runs here #act call_main(integration_test_case) with open(integrationtestrunoutputfolderpath+"integration_test_output.json") as json_file: integration_test_output_dict = json.load(json_file) #assert
Source: Python Questions