Skip to content

Commit

Permalink
Make tests work on mac again
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Nov 24, 2024
1 parent 143e5e5 commit f11556b
Showing 1 changed file with 24 additions and 36 deletions.
60 changes: 24 additions & 36 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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 = {}

Expand All @@ -44,15 +13,34 @@ 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())
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()

0 comments on commit f11556b

Please sign in to comment.