1

How can I use a pseudoterminal in python to emulate a serial port

view story
linux-howto

http://stackoverflow.com – I am creating a python application using twisted which reads lines from a serial port. In order to (unit)test that app without having to connect an actual device to the serial port (also on pc's without an actual serial port) I would like to create a python script/app that sets up a virtual serial port and writes to it, so the twisted app can connect to the other end of the virtual serial port and read from it. This way I can write some unittests. I found this is possible using pseudo terminals in linux. I also found a working example script on http://askubuntu.com/questions/9396/virtual-seri (HowTos)