I am trying to write a unit test for a class I built, its something like this:
Class A:
def __init__():
self.varA = funcA()
self._exe_path= "path/to/executable"
def funcA():
varB=""
output=subprocess.run("mode", capture_output=True, text=True, shell=True)
for i in output.stdout:
if "XYZ" in i:
varA=word[:-1]
else:
del word
if varB=="":
raise CustomException("message")
return varB
def func_to_test(param1):
subprocess.run("{} {} command{}".format(self._exe_path, self.varA, param1)
How can I unit test my function func_to_test()?