Add confirmation for this destructive test

This commit is contained in:
Adrien Ferrand 2020-01-31 20:35:31 +01:00
parent 44eba5e5e9
commit 44f1596853
2 changed files with 26 additions and 1 deletions

View file

@ -48,7 +48,7 @@ jobs:
displayName: Prepare Certbot-CI
- script: |
set PATH=%ProgramFiles(x86)%\Certbot\bin;%PATH%
venv\Scripts\python -m pytest certbot-ci\windows_installer_integration_tests --installer-path $(Build.SourcesDirectory)\bin\certbot-beta-installer-win32.exe
venv\Scripts\python -m pytest certbot-ci\windows_installer_integration_tests --confirm --installer-path $(Build.SourcesDirectory)\bin\certbot-beta-installer-win32.exe
displayName: Run windows installer integration tests
- script: |
set PATH=%ProgramFiles(x86)%\Certbot\bin;%PATH%

View file

@ -9,6 +9,8 @@ See https://docs.pytest.org/en/latest/reference.html#hook-reference
from __future__ import print_function
import os
import pytest
ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
@ -22,3 +24,26 @@ def pytest_addoption(parser):
'nsis', 'certbot-beta-installer-win32.exe'),
help='set the path of the windows installer to use, default to '
'CERTBOT_ROOT_PATH\\windows-installer\\build\\nsis\\certbot-beta-installer-win32.exe')
parser.addoption('--confirm', action='store_true',
help='if set, this test will not ask for user confirmation before running')
def pytest_configure(config):
"""
Standard pytest hook used to add a configuration logic for each node of a pytest run.
:param config: the current pytest configuration
"""
if not config.option.confirm:
capture_manager = config.pluginmanager.getplugin('capturemanager')
try:
capture_manager.suspendcapture(in_=True)
print('++ WARNING ++')
print('-------------')
print('This integration test will install Certbot on your machine.')
print('At the end of the test you will need to manually uninstall it.')
print('-------------')
input('Please press ENTER to continue, or CTRL+C to cancel.')
finally:
capture_manager.resumecapture()