tests: functional: Set default screenshots dir as ./screenshots

Tests:

- Fail a functional test using assert False. Notice that the screenshot is taken
in ./screenshots directory.

- Pass --splinter-screenshot-dir=foo and notice that the screenshot is taken in
./foo directory.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-01-21 13:32:49 -08:00 committed by James Valleroy
parent 98cfa321cb
commit 81814e487f
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -168,6 +168,17 @@ def fixture_call_action(request, capsys, actions_module):
return _call_action
@pytest.fixture(name='splinter_screenshot_dir', scope='session')
def fixture_splinter_screenshot_dir(request):
"""Set default screenshot directory to ./screenshots.
This can be overridden using --splinter-screenshot-dir=foo as the option.
"""
option = request.config.getoption('--splinter-screenshot-dir')
screenshots_dir = option if option != '.' else './screenshots'
return os.path.abspath(screenshots_dir)
@pytest.fixture(autouse=True)
def fixture_fix_session_browser_screenshots(request):
"""Fix a bug in pytest-splinter for screenshots.