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 authored and James Valleroy committed 2022-01-22 13:15:25 -05:00
1 parent 98cfa321cb
commit 81814e487f
1 file changed
+11
+11
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.