Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        2年前关闭。
                                                                                            
                
        
如何编写自动测试以检查vi编辑器是否可以使用Python正确编程?

最佳答案

保存包含vi命令的脚本,如下所示。

           cat script.sh
           vi abc.txt <<INPUT
           i
           Line 1
           Line 2
           ^[
           ZZ
           INPUT


使用python subprocess.check_call检查执行状态

subprocess.check_call(["script.sh" , "arg1"])


这将运行带有参数的命令(script.sh)(如果需要)。等待命令完成。如果返回码为零,则返回,
 否则引发CalledProcessError Exception

10-06 01:55