-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Is it possible to prompt the user to do something during py.test runs? #4210
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
Comments
Pytest isn't designed to manage manual tests, I wonder if there are 3rd party tools that support this |
There is pytest-interactive, which interactively lets you select which tests to run. It might be a starting point to write a plugin which lets tests obtain user input. I believe we can close this though, as pytest isn't designed for this as @RonnyPfannschmidt mentioned. |
There is actually a solution (workaround?) in that you can temporarily suspend capture to handle the user interaction (suggested by @nicoddemus himself, even): |
Also, at the time it was great to see that it was possible to use pytest in this hardware-testing scenario, even if it may not be designed for this... ;-) |
@bilderbuchi It only works for me when used in the test itself, but not as a fixture. |
Hm, thanks, i'll have to check again then, it's been a while since I ran that code, it worked at the time at least. |
@blueyed I have updated the SO answer to the new names suspend_global_capture and resume_global_capture and confirmed that it works with pytest 4.0.2. |
@bilderbuchi import pytest
@pytest.fixture(scope="module")
def disable_capture_module(pytestconfig):
capmanager = pytestconfig.pluginmanager.getplugin('capturemanager')
# capmanager.suspend_global_capture(in_=True)
# yield
# capmanager.resume_global_capture()
with capmanager.global_and_fixture_disabled():
yield
def test_with_fixture(disable_capture_module):
for i in range(1, 10):
print(i)
def test_inline(pytestconfig):
capmanager = pytestconfig.pluginmanager.getplugin('capturemanager')
with capmanager.global_and_fixture_disabled():
for i in range(1, 10):
print(i) Will result in the following when run with
@nicoddemus |
Not sure from the top of my head... at first glance it should probably work. |
Ah I understand now. No idea why that is, though. |
I am going to be writing a full system test for our customer to be able to check all of our systems during configuration after unit tests pass to ensure everything is working properly. For unit testing the code, py.test works great. However, we have a PCB that provides critical information during testing and need to be able to prompt the user to perform certain tasks so that the system can check these conditions to ensure they are as expected. Here is a simple example of what I am trying to do in a test function/class:
The text was updated successfully, but these errors were encountered: