Pytest skiporimport matlab.engine

PyTest can work with Matlab Engine if the Matlab Engine is setup. Use a try-catch to ensure any non-functioning Matlab Engine issue is skipped.

import pytest


def test_me():
    try:
        mateng = pytest.importorskip("matlab.engine")
    except Exception:  # can also get RuntimeError, let's just catch all
        pytest.skip("Matlab engine not available")

    eng = mateng.start_matlab("-nojvm")
    # test code