Use python subprocess module like a command line simulator

前端 未结 2 631
眼角桃花
眼角桃花 2021-01-23 03:21

I am writing a test framework in Python for a command line application. The application will create directories, call other shell scripts in the current directory and will outpu

2条回答
  •  半阙折子戏
    2021-01-23 03:27

    Instead of using plain subprocess you might find Python sh library very useful:

    http://amoffat.github.com/sh/

    Here is an example how to build in an asynchronous interaction loop with sh:

    http://amoffat.github.com/sh/tutorials/2-interacting_with_processes.html

    Another (old) library for solving this problem is pexpect:

    http://www.noah.org/wiki/pexpect

提交回复
热议问题