Skip to content

Commit

Permalink
Skip tests needing toulbar2 when not available
Browse files Browse the repository at this point in the history
  • Loading branch information
nhuet authored and g-poveda committed Oct 24, 2024
1 parent b599601 commit 394926e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
21 changes: 14 additions & 7 deletions tests/coloring/solvers/test_toulbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
import pytest

from discrete_optimization.coloring.parser import get_data_available, parse_file
from discrete_optimization.coloring.problem import (
ColoringProblem,
transform_color_values_to_value_precede_on_other_node_order,
)
from discrete_optimization.coloring.problem import ColoringProblem
from discrete_optimization.coloring.solvers.greedy import (
GreedyColoringSolver,
NxGreedyColoringMethod,
)
from discrete_optimization.coloring.solvers.toulbar import ToulbarColoringSolver
from discrete_optimization.generic_tools.callbacks.early_stoppers import (
NbIterationStopper,
)

try:
import pytoulbar2
except ImportError:
toulbar_available = False
else:
toulbar_available = True


@pytest.mark.skipif(
not toulbar_available, reason="You need Toulbar2 to test this solver."
)
def test_coloring_toulbar():
small_example = [f for f in get_data_available() if "gc_20_1" in f][0]
problem: ColoringProblem = parse_file(small_example)
Expand All @@ -28,6 +32,9 @@ def test_coloring_toulbar():
print(problem.evaluate(sol))


@pytest.mark.skipif(
not toulbar_available, reason="You need Toulbar2 to test this solver."
)
def test_toulbar_coloring_ws():
file = [f for f in get_data_available() if "gc_20_7" in f][0]
color_problem = parse_file(file)
Expand Down
16 changes: 13 additions & 3 deletions tests/maximum_independent_set/solvers/test_toulbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# LICENSE file in the root directory of this source tree.
import pytest

from discrete_optimization.generic_tools.callbacks.early_stoppers import (
NbIterationStopper,
)
from discrete_optimization.maximum_independent_set.parser import (
dimacs_parser_nx,
get_data_available,
Expand All @@ -16,7 +13,17 @@
ToulbarMisSolver,
)

try:
import pytoulbar2
except ImportError:
toulbar_available = False
else:
toulbar_available = True


@pytest.mark.skipif(
not toulbar_available, reason="You need Toulbar2 to test this solver."
)
def test_mis_toulbar():
small_example = [f for f in get_data_available() if "1dc.64" in f][0]
mis_model: MisProblem = dimacs_parser_nx(small_example)
Expand All @@ -27,6 +34,9 @@ def test_mis_toulbar():
assert mis_model.satisfy(sol)


@pytest.mark.skipif(
not toulbar_available, reason="You need Toulbar2 to test this solver."
)
def test_mis_toulbar_ws():
small_example = [f for f in get_data_available() if "1dc.64" in f][0]
mis_model: MisProblem = dimacs_parser_nx(small_example)
Expand Down

0 comments on commit 394926e

Please sign in to comment.