我用python unitest编写了以下代码以获得minikube ip。
def get_minikube_ip(self):
process = subprocess.Popen(["minikube", "ip"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait()
if process.stdout is not None:
minikube_ip = process.stdout.readline().strip()
if not minikube_ip:
raise Exception("Minikube is not running. Please, start minikube first.")
return minikube_ip
raise Exception("Minikube is not running. Please, start minikube first.")
但是在运行unitest时,出现OSError错误:[Errno 2]没有此类文件或目录。我通过参考堆栈溢出中其他人提出的类似问题尝试了不同的解决方案,但无法解决。