>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

>Half century of technical know-how sharing

>It’s 50th post on this blog. I am happy with my contribution. Learning is a continuous process and I am an active participant. Today’s post will talk of something that I had never imagined to do in my development career: Testing.

Testing of the product is an interesting job, especially when you are a new user. Past two weeks, I am testing the product I’d be developing.

I’m sharing my experience here:

– Don’t test just for sake of doing it; Understand the ecosystem in which your product would be working.
– Take generous logs of your testing.
– Keep an eye on what you can improve: Be it a process or a feature.
– Try to automate processes if possible.
– Try feeding weird input to your product.
– Testing is learning. You become a very good user of your product.