How to test Python readline completion?
问题 I'm writing a command-line interface in Python. It uses the readline module to provide command history and completion. While everything works fine in interactive mode, I'd like to run automated tests on the completion feature. My naive first try involved using a file for standard input: my_app < command.file The command file contained a tab, in the hopes that it would invoke the completion feature. No luck. What's the right way to do the testing? 回答1: For this I would use Pexpect (Python