import os import re import shutil def checkOutput(output): for line in output.split('\n'): if line == 'Hello world!': return True return False def test_c(): print(os.getcwd()) fh = os.popen("./helloworld", mode='r', buffering=-1) output = fh.read() retcode = fh.close() assert retcode == None and checkOutput(output)