From 81814e487f4cdc39f411a4520b2d327dc1e979c2 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 21 Jan 2022 13:32:49 -0800 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- conftest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/conftest.py b/conftest.py index 5c2706f4a..e84b08e08 100644 --- a/conftest.py +++ b/conftest.py @@ -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.