Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
dialogue-tester
Readme
The Dialogue
class helps testing REPLs (interactive interpreters with a Read-Eval-Print-Loop).
Given a multi-line interactive session transcript, a Dialogue
instance emulates user interactions by offering a fake_input
method which can replace the input
built-in function in Python 3.
You can code your REPL function to accept an input function as an optional argument, or you can monkey patch Python's input
built-in. Either way, you replace the standard input
with the fake_input
method bound to a Dialogue
instance. Each time it is invoked, this method will print the next prompt and fake user input from the session transcript, then return the same user input string to the REPL for processing.
The Dialogue.session
instance attribute holds a multi-line string with all the prompts, user inputs and the outputs expected from the REPL under test. This is used to assert
the test case.
See the dialogue_test.py
module for two simple REPLs that exercise the Dialogue
class.
Note: the
.session
attribute is normalized with thedialogue.normalize()
function. Use that function to normalize the output captured by your testing framework as well. This normalization removes trailing whitespace from each line, preserving only the newlines separating them, and also removes leading and trailing whitespace from the session as a whole. This avoids many issues with linters and IDEs complaining about trailing whitespace, and also makes it easier to edit the session examples in tests. See the tests in this package for use ofnormalize
in test assertions.
FAQs
Dialogue class for testing REPLs
We found that dialogue-tester demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.