Raise exception if script fails
问题 I have a python script, tutorial.py. I want to run this script from a file test_tutorial.py, which is within my python test suite. If tutorial.py executes without any exceptions, I want the test to pass; if any exceptions are raised during execution of tutorial.py, I want the test to fail. Here is how I am writing test_tutorial.py, which does not produce the desired behavior: from os import system test_passes = False try: system("python tutorial.py") test_passes = True except: pass assert