Python subprocess
I thought this was cool because it made writing a quick test for my simple UDP server really clean and easy. What I needed to do was spawn another process to run alongside my script. In this case it was this subprocess that I wanted to test. Python subprocess made this really easy.
The script starts the udps server in a child process using subprocess.Popen and then sends a UDP datagram to the udps server, which gets written to the server log file. The test verification is the printed content of the udps.log file created by the udps server subprocess, and then subprocess.Popen.kill is a nice simple way to end the udps process.
Comments [0]