1+ classdef tInstall < matlab .unittest .TestCase
2+ % Verify installation of matlab engine
3+
4+ % Copyright 2023 Mathworks, Inc.
5+
6+ properties (Constant )
7+ MATLABVersion = string(ver(' MATLAB' ).Version) % Example: 9.14
8+ end
9+
10+ methods (Test )
11+ function installNoVersionSpecified(testCase )
12+ [status , out ] = system(" pip install matlabengine" );
13+ addTeardown(testCase , @system , " pip uninstall -y matlabengine" );
14+ verifyEqual(testCase , status , 0 , out )
15+ verifyInstallation(testCase )
16+ end
17+
18+ function installMatchingEngine(testCase )
19+ [status , out ] = system(" pip install matlabengine==" + testCase .MATLABVersion + " .*" );
20+ addTeardown(testCase , @system , " pip uninstall -y matlabengine" );
21+ verifyEqual(testCase , status , 0 , out )
22+ verifyInstallation(testCase )
23+ end
24+ end
25+
26+ methods
27+ function verifyInstallation(testCase )
28+ % Verify installation by calling functions in matlab engine
29+ % Share this session and see if find_matlab can find it.
30+ sharedEngineName = matlab .engine .engineName ;
31+ if isempty(sharedEngineName )
32+ sharedEngineName = ' MATLAB_tInstall' ;
33+ matlab .engine .shareEngine(sharedEngineName )
34+ end
35+ pySharedEngineName = char(py .matlab .engine .find_matlab());
36+ verifySubstring(testCase , pySharedEngineName , sharedEngineName )
37+ end
38+ end
39+ end
0 commit comments