diff --git a/setup.py b/setup.py index 7223d890d..41349fbd6 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def get_version(rel_path): zip_safe=False, install_requires=[ 'ortools>=9.9', - 'numpy>=1.5', + 'numpy>=1.5,<2', 'setuptools', ], extras_require={ diff --git a/tests/test_examples.py b/tests/test_examples.py index 1db1a819a..a69ede791 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -24,9 +24,15 @@ SKIPPED_EXAMPLES = [ "ocus_explanations.py", # waiting for issues to be resolved - "psplib.py" # randomly fails on github due to file creation + "psplib.py", # randomly fails on github due to file creation ] +SOLVER_SPECIFIC_EXAMPLES = { + "pysat": ["prob044_steiner.py"], + "exact": ["exact_maximal_propagate.py"] +} +_SOLVER_SPECIFIC_EXAMPLES_REVERSE = {v:k for k,vs in SOLVER_SPECIFIC_EXAMPLES.items() for v in vs} + SKIP_MIP = ['npuzzle.py', 'tst_likevrp.py', 'sudoku_', 'pareto_optimal.py', 'prob009_perfect_squares.py', 'blocks_world.py', 'flexible_jobshop.py', 'mario', 'pareto_optimal','prob006_golomb.py', 'tsp.py', 'prob028_bibd.py', 'prob001_car_sequence.py' @@ -59,6 +65,13 @@ def test_example(solver, example): return pytest.skip(reason=f"exclude {example} for {solver}, too slow or solver-specific") if solver == 'minizinc' and any(x in example for x in SKIP_MZN): return pytest.skip(reason=f"exclude {example} for {solver}, too slow or solver-specific") + # Skip solver specific tests for which the solver is not installed + for skip_name in _SOLVER_SPECIFIC_EXAMPLES_REVERSE.keys(): + if skip_name in example: + if not SolverLookup.lookup(_SOLVER_SPECIFIC_EXAMPLES_REVERSE[skip_name]).supported(): + pytest.skip(f"Skipped {example} due to solver {_SOLVER_SPECIFIC_EXAMPLES_REVERSE[skip_name]} not being available on the current system.") + else: + break base_solvers = SolverLookup.base_solvers try: @@ -95,4 +108,11 @@ def test_advanced_example(example): """Loads the advanced example file and executes its __main__ block with no default solver set.""" if any(skip_name in example for skip_name in SKIPPED_EXAMPLES): pytest.skip(f"Skipped {example}, waiting for issues to be resolved") + # Skip solver specific tests for which the solver is not installed + for skip_name in _SOLVER_SPECIFIC_EXAMPLES_REVERSE.keys(): + if skip_name in example: + if not SolverLookup.lookup(_SOLVER_SPECIFIC_EXAMPLES_REVERSE[skip_name]).supported(): + pytest.skip(f"Skipped {example} due to solver {_SOLVER_SPECIFIC_EXAMPLES_REVERSE[skip_name]} not being available on the current system.") + else: + break test_example(None, example)