-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing questionary flows #35
Comments
That is a really good idea, and actually something we have been struggling with in https://github.com/rasahq/rasa as well. I need to digg a little deeper, but ideally, there should be a way to mock the actual IO, but provided by questionary (as you said, I don't think it is save for the user to mock these kind of things, but it would be fine to provide & test it as part of the library). Could be something like from questionary.test import mocked_input
# ...
def test_input_questions():
with mocked_input({"conditional_step": "Yes", "next_question": "questionary"}):
vals = prompt(questions)
# ... |
I can see that the test suite has some interesting utils to test itself: Lines 12 to 77 in 1a2c99b
How about bundling all those utils in Notice that some good answer to this might land in prompt-toolkit/python-prompt-toolkit#1243. |
I've been using |
The arrow-keys are such a great feature of questionary. Did anybody get the arrow-keys working for their testing environment? And if yes, could you post the code? |
Some of our own tests use the arrow keys. You should be able to get this working in your own code by copying questionary/tests/prompts/test_select.py Line 53 in 2979fb8
As @yajo has suggested, we should expose these in the Questionary API so that people can more easily test their projects! |
Any update on this? Currently we are vendoring the |
@pmeier No update at the moment, but happy to provide feedback on any PRs which attempt to implement this. |
I'll clean up our test code to see what exactly we need and send a PR afterwards. |
It would be great if questionary would have an easy way to test input flows
For example (reusing my example flow from #34):
Now by calling
test_prompt()
with an input string (or List - which is probably easier to compile) we can run through the whole workflow, and verify that all keys are populated as expected.This would allow proper CI for more complex flows ... which base one input on top of the other as in the question-flow above.
I suspect it would be possible by mocking some internals of questionary - but i see this as a dangerous approach as every minor change in these mocked functions would probably lead to an error in my tests.
Most of the code / logic should already be available as part of the tests for questionary - however that's not available when installing from pypi...
The text was updated successfully, but these errors were encountered: