>Expect Pexpect: Python module to help you automate interactive tests

>Many a times we encounter writing a code that requires user input to proceed. Testing and validating such an application can become tedious and frustating. Python implements an elegant solution to cut down the effort needed to “talk to application”.

This is called pexpect module, borrowed from Tcl “expect”. Pexpect is a tool for controlling and automoating programs. It simple “fools” the application with an user input. It runs the program and monitors the output. When output matches a given pattern, it respond to application mimicking the human intervention.

Pexpect can be extensively used in testing and automation. I found it particularly useful for interacting with application like ssh, ftp, passwd, telnet etc.

It comes packaged with standard Ubuntu 9.10. The version of Python used by me is:

$python –version
Python 2.6.4rc2

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: