Skip to content

Commit

Permalink
Add skip for slow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aragilar committed Aug 13, 2022
1 parent ebe4de0 commit a19d4f6
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

from logbook import StderrHandler
Expand All @@ -6,6 +7,7 @@

from disc_solver.solve import solve
from disc_solver.float_handling import float_type as FLOAT_TYPE
from disc_solver.utils import str_to_bool

PLOT_FILE = "plot.png"

Expand Down Expand Up @@ -49,6 +51,24 @@
USE_E_R_SOLUTIONS = [
"mod_hydro_solution_use_E_r",
]
CAN_BE_SKIPPED = {
"hydrostatic_solution_default",
"hydrostatic_solution_no_internal",
"mcmc_solution_no_internal",
"mod_hydro_solution_default",
"mod_hydro_solution_no_internal",
"mod_hydro_solution_use_E_r",
"sonic_root_solution_default",
"sonic_root_solution_no_internal",
}


@pytest.fixture(scope="session")
def skip_slow_tests():
dont_skip = os.environ.get("DS_RUN_SLOW_TESTS")
if dont_skip is None:
return True
return str_to_bool(dont_skip)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -174,37 +194,65 @@ def mod_hydro_solution_use_E_r(tmpdir_factory):


@pytest.fixture(scope="session", params=ALL_SOLUTIONS)
def solution(request):
def solution(request, skip_slow_tests):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=DEFAULT_SOLUTIONS)
def solution_default(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=NO_INTERNAL_SOLUTIONS)
def solution_no_internal(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=MULTI_SOLUTIONS)
def solutions_many(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=TAYLOR_SOLUTIONS)
def solution_taylor(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=DERIV_SOLUTIONS)
def solution_deriv(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


@pytest.fixture(scope="session", params=DERIV_NO_INTERNAL_SOLUTIONS)
def solution_deriv_no_internal(request):
if skip_slow_tests and request.param in CAN_BE_SKIPPED:
pytest.skip(
"Skipping as {} in skipable solutions".format(request.param)
)
return request.getfixturevalue(request.param)


Expand Down

0 comments on commit a19d4f6

Please sign in to comment.