python-cmd

Create automated tests for interactive shell based on Python's cmd module

给你一囗甜甜゛ 提交于 2020-01-04 04:13:24
问题 I am building an interactive shell using Python 3 and the cmd module. I have already written simple unit tests using py.test to test the individual functions, such as the do_* functions. I'd like to create more comprehensive tests that actually interact with the shell itself by simulating a user's input. For example, how could I test the following simulated session: bash$ console-app.py md:> show options Available Options: ------------------ HOST The IP address or hostname of the machine to

Python Twisted integration with Cmd module

旧城冷巷雨未停 提交于 2019-12-07 01:58:58
问题 I like Python's Twisted and Cmd. I want to use them together. I got some things working, but so far I haven't figured out how to make tab-completion work, because I don't see how to receive tab keypres events right away (without pressing Enter) in Twisted's LineReceiver. Here's my code so far: #!/usr/bin/env python from cmd import Cmd from twisted.internet import reactor from twisted.internet.stdio import StandardIO from twisted.protocols.basic import LineReceiver class CommandProcessor(Cmd):

Python Twisted integration with Cmd module

拥有回忆 提交于 2019-12-05 08:20:31
I like Python's Twisted and Cmd . I want to use them together. I got some things working, but so far I haven't figured out how to make tab-completion work, because I don't see how to receive tab keypres events right away (without pressing Enter) in Twisted's LineReceiver. Here's my code so far: #!/usr/bin/env python from cmd import Cmd from twisted.internet import reactor from twisted.internet.stdio import StandardIO from twisted.protocols.basic import LineReceiver class CommandProcessor(Cmd): def do_EOF(self, line): return True class LineProcessor(LineReceiver): from os import linesep as