From 4f79096d07a08b91341bebcfbe24651c214116e8 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 6 Oct 2021 13:58:18 -0400 Subject: [PATCH] conftest: Skip functional tests if splinter not importable Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- conftest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conftest.py b/conftest.py index d5551a936..af2d577b8 100644 --- a/conftest.py +++ b/conftest.py @@ -11,6 +11,18 @@ from unittest.mock import patch import pytest +try: + importlib.import_module('splinter') + _splinter_available = True +except ImportError: + _splinter_available = False + + +def pytest_ignore_collect(path, config): + """Ignore functional tests when splinter is not available.""" + if path.basename == 'test_functional.py': + return not _splinter_available + def pytest_addoption(parser): """Add a command line option to run functional tests."""