Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused test markers #9531

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ci/testkomodo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ run_ert_with_opm() {

run_everest_tests() {
python -m pytest tests/everest -s \
--ignore-glob "*test_visualization_entry*" \
-m "not requires_eclipse"
--ignore-glob "*test_visualization_entry*"

}

Expand Down
63 changes: 63 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import pytest


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
parser.addoption(
"--eclipse-simulator",
action="store_true",
default=False,
help="Defaults to not running tests that require eclipse.",
)
parser.addoption(
"--openpbs",
action="store_true",
default=False,
help="Run OpenPBS tests against the real cluster",
)
parser.addoption(
"--lsf",
action="store_true",
default=False,
help="Run LSF tests against the real cluster.",
)
parser.addoption(
"--slurm",
action="store_true",
default=False,
help="Run Slurm tests against a real cluster.",
)
parser.addoption("--show-gui", action="store_true", default=False)


def pytest_collection_modifyitems(config, items):
for item in items:
fixtures = getattr(item, "fixturenames", ())
if "qtbot" in fixtures or "qapp" in fixtures or "qtmodeltester" in fixtures:
item.add_marker("requires_window_manager")

# Override Python's excepthook on all "requires_window_manager" tests
for item in items:
if item.get_closest_marker("requires_window_manager"):
item.fixturenames.append("_qt_excepthook")
item.fixturenames.append("_qt_add_search_paths")
if item.get_closest_marker("requires_eclipse") and not config.getoption(
"--eclipse-simulator"
):
item.add_marker(pytest.mark.skip("Requires eclipse"))

if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
skip_quick = pytest.mark.skip(
reason="skipping quick performance tests on --runslow"
)
for item in items:
if "quick_only" in item.keywords:
item.add_marker(skip_quick)
else:
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
62 changes: 0 additions & 62 deletions tests/ert/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,37 +265,6 @@ def hide_window(request):
os.environ["QT_QPA_PLATFORM"] = old_value


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
parser.addoption(
"--eclipse-simulator",
action="store_true",
default=False,
help="Defaults to not running tests that require eclipse.",
)
parser.addoption(
"--openpbs",
action="store_true",
default=False,
help="Run OpenPBS tests against the real cluster",
)
parser.addoption(
"--lsf",
action="store_true",
default=False,
help="Run LSF tests against the real cluster.",
)
parser.addoption(
"--slurm",
action="store_true",
default=False,
help="Run Slurm tests against a real cluster.",
)
parser.addoption("--show-gui", action="store_true", default=False)


@pytest.fixture
def _qt_excepthook(monkeypatch):
"""Hook into Python's unhandled exception handler and quit Qt if it's
Expand All @@ -313,37 +282,6 @@ def excepthook(cls, exc, tb):
monkeypatch.setattr(sys, "excepthook", excepthook)


def pytest_collection_modifyitems(config, items):
for item in items:
fixtures = getattr(item, "fixturenames", ())
if "qtbot" in fixtures or "qapp" in fixtures or "qtmodeltester" in fixtures:
item.add_marker("requires_window_manager")

# Override Python's excepthook on all "requires_window_manager" tests
for item in items:
if item.get_closest_marker("requires_window_manager"):
item.fixturenames.append("_qt_excepthook")
item.fixturenames.append("_qt_add_search_paths")
if item.get_closest_marker("requires_eclipse") and not config.getoption(
"--eclipse-simulator"
):
item.add_marker(pytest.mark.skip("Requires eclipse"))

if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
skip_quick = pytest.mark.skip(
reason="skipping quick performance tests on --runslow"
)
for item in items:
if "quick_only" in item.keywords:
item.add_marker(skip_quick)
else:
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


def _run_snake_oil(source_root):
shutil.copytree(
os.path.join(source_root, "test-data/ert", "snake_oil"), "test_data"
Expand Down
3 changes: 0 additions & 3 deletions tests/everest/test_egg_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
hide_opm,
skipif_no_everest_models,
skipif_no_opm,
skipif_no_simulator,
)

CONFIG_FILE = "everest/model/config.yml"
Expand Down Expand Up @@ -665,7 +664,6 @@ def test_init_egg_model(copy_egg_test_data_to_tmp):

@skipif_no_everest_models
@pytest.mark.everest_models_test
@skipif_no_simulator
@pytest.mark.requires_eclipse
def test_run_egg_model(copy_egg_test_data_to_tmp):
config = EverestConfig.load_file(CONFIG_FILE)
Expand Down Expand Up @@ -796,7 +794,6 @@ def test_egg_model_wells_json_output_no_none(copy_egg_test_data_to_tmp):

@skipif_no_everest_models
@pytest.mark.everest_models_test
@skipif_no_simulator
@pytest.mark.requires_eclipse
@pytest.mark.timeout(0)
def test_egg_snapshot(snapshot, copy_egg_test_data_to_tmp):
Expand Down
8 changes: 3 additions & 5 deletions tests/everest/test_everest_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
from ert.run_models.everest_run_model import EverestRunModel
from everest.config import EverestConfig

NO_PROJECT_RES = (
os.environ.get("NO_PROJECT_RES", False),
"Skipping tests when no access to /project/res",
)
from .utils import skipif_no_everest_models


@pytest.mark.skipif(NO_PROJECT_RES[0], reason=NO_PROJECT_RES[1])
@skipif_no_everest_models
oyvindeide marked this conversation as resolved.
Show resolved Hide resolved
@pytest.mark.requires_eclipse
def test_init_no_project_res(copy_egg_test_data_to_tmp):
config_file = os.path.join("everest", "model", "config.yml")
config = EverestConfig.load_file(config_file)
Expand Down
2 changes: 0 additions & 2 deletions tests/everest/test_repo_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def is_config(fn):
config_files = [fn for cdir in config_folders for fn in _get_all_files(cdir)]
config_files = filter(is_config, config_files)

if os.environ.get("NO_PROJECT_RES", False):
config_files = [f for f in config_files if "examples/egg" not in f]
try:
get_ropt_plugin_manager().get_plugin("optimizer", "scipy/default")
except ROptConfigError:
Expand Down
8 changes: 0 additions & 8 deletions tests/everest/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ def skipif_no_opm(function):
return pytest.mark.skipif(not has_opm(), reason="OPM not found")(function)


def skipif_no_simulator(function):
"""Decorator to skip a test if no project res is available is not available"""
return pytest.mark.skipif(
condition=os.environ.get("NO_PROJECT_RES", False),
reason="Skipping tests when no access to /project/res",
)(function)


def skipif_no_everest_models(function):
"""Decorator to skip a test if everest-models is not available"""
spec = importlib.util.find_spec("everest_models")
Expand Down
Loading