测试交互式python程序 [英] testing interactive python programs

查看:42
本文介绍了测试交互式python程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道python有哪些测试工具支持交互式程序的测试.例如,我有一个应用程序启动:

I would like to know which testing tools for python support the testing of interactive programs. For example, I have an application launched by:

$ python dummy_program.py 

>> Hi whats your name? Joseph

我想对 Joseph 进行检测,以便我可以模拟这种交互行为.

I would like to instrument Joseph so I can emulate that interactive behaviour.

推荐答案

如果您正在测试交互式程序,请考虑使用 期待.它专为与控制台程序交互而设计(不过,更多用于自动化任务而不是测试).

If you are testing an interactive program, consider using expect. It's designed specifically for interacting with console programs (though, more for automating tasks rather than testing).

如果您不喜欢期望基于 (tcl) 的语言,您可以尝试 pexpect这也使得与控制台程序交互变得容易.

If you don't like the language expect is based on (tcl) you can try pexpect which also makes it easy to interact with a console program.

这篇关于测试交互式python程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆