diff --git a/tests/conftest.py b/tests/conftest.py index 02589dc..15354f5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,35 +1,4 @@ import pytest -import platform - -model_interface_dict = {} - -import pyoptinterface.gurobi as gurobi - -if gurobi.is_library_loaded(): - model_interface_dict["gurobi"] = gurobi.Model - -import pyoptinterface.copt as copt - -if copt.is_library_loaded(): - model_interface_dict["copt"] = copt.Model - -import pyoptinterface.mosek as mosek - -if mosek.is_library_loaded(): - model_interface_dict["mosek"] = mosek.Model - -import pyoptinterface.highs as highs - -if highs.is_library_loaded(): - model_interface_dict["highs"] = highs.Model - - -@pytest.fixture(params=model_interface_dict.keys()) -def model_interface(request): - name = request.param - model_interface_class = model_interface_dict[name] - return model_interface_class() - ipopt_model_dict = {} @@ -44,11 +13,9 @@ def c(): return ipopt.Model(jit="C") ipopt_model_dict["ipopt_llvm"] = llvm - - if platform.system() != "Darwin": - # Skip the C JIT test on macOS, but it works correctly when run in the terminal - # needs further investigation - ipopt_model_dict["ipopt_c"] = c + # On macOS, loading dynamic library of Gurobi/COPT/Mosek before loading libtcc will cause memory error + # The reason is still unclear + ipopt_model_dict["ipopt_c"] = c @pytest.fixture(params=ipopt_model_dict.keys()) @@ -56,3 +23,24 @@ def ipopt_model_ctor(request): name = request.param ctor = ipopt_model_dict[name] return ctor + + +model_interface_dict = {} + +from pyoptinterface import gurobi, copt, mosek, highs + +if gurobi.is_library_loaded(): + model_interface_dict["gurobi"] = gurobi.Model +if copt.is_library_loaded(): + model_interface_dict["copt"] = copt.Model +if mosek.is_library_loaded(): + model_interface_dict["mosek"] = mosek.Model +if highs.is_library_loaded(): + model_interface_dict["highs"] = highs.Model + + +@pytest.fixture(params=model_interface_dict.keys()) +def model_interface(request): + name = request.param + model_interface_class = model_interface_dict[name] + return model_interface_class()