HelloWorld/tests/global_fns.py
2022-08-29 00:10:10 -05:00

34 lines
864 B
Python

import os
import re
import shutil
def checkOutput(output):
"""
Ensure hello world is in string.
return: whether hello world is present
"""
return output == 'Hello world!\n'
def runCommand(command):
"""
Define a function to run a shell commmand and return the output
param command: command to run
return: Whether retcode is 0
"""
fh = os.popen(command, mode='r', buffering=-1)
output = fh.read()
retcode = fh.close()
assert retcode == None
def runCommandAndOutputCheck(command):
"""
Define a function to run a shell command and ensure output is correct
param command: command
return: Whether retcode is 0 && output matches test.
"""
fh = os.popen(command, mode='r', buffering=-1)
output = fh.read()
retcode = fh.close()
assert retcode == None and CheckOutput(output)