1
- import warnings
1
+ import os
2
2
from pathlib import Path
3
3
4
4
import pytest
5
+ import re
5
6
6
7
from cadet import Cadet
7
8
9
+ # Full path to cadet.dll or cadet.so, that is different from the system/conda cadet
8
10
full_path_dll = Path (r"C:\Users\ronal\Documents\CADET\out\install\aRELEASE\bin\cadet.dll" )
9
- install_path_dll = full_path_dll .parent .parent
10
11
11
12
install_path_conda = Cadet .autodetect_cadet ()
12
13
@@ -16,42 +17,48 @@ def test_autodetection():
16
17
assert sim .install_path == install_path_conda
17
18
assert sim .cadet_dll_path .parent .parent == install_path_conda
18
19
assert sim .cadet_cli_path .parent .parent == install_path_conda
19
- assert sim .cadet_runner .cadet_path .suffix != " dll"
20
+ assert sim .cadet_runner .cadet_path .suffix not in [ ". dll", ".so" ]
20
21
21
22
22
23
def test_install_path ():
23
24
sim = Cadet (install_path = full_path_dll , use_dll = True )
24
25
assert sim .cadet_dll_path == full_path_dll
25
- assert sim .cadet_runner .cadet_path .suffix == ".dll"
26
+ assert sim .cadet_runner .cadet_path .suffix in [ ".dll" , ".so" ]
26
27
27
28
sim = Cadet ()
28
29
sim .install_path = full_path_dll .parent .parent
29
30
sim .use_dll = True
30
31
assert sim .cadet_dll_path == full_path_dll
31
- assert sim .cadet_runner .cadet_path .suffix == ".dll"
32
+ assert sim .cadet_runner .cadet_path .suffix in [ ".dll" , ".so" ]
32
33
33
34
sim = Cadet ()
34
35
with pytest .deprecated_call ():
35
36
sim .cadet_path = full_path_dll .parent .parent
36
37
37
38
sim .use_dll = True
38
39
assert sim .cadet_dll_path == full_path_dll
39
- assert sim .cadet_runner .cadet_path .suffix == ".dll"
40
+ assert sim .cadet_runner .cadet_path .suffix in [ ".dll" , ".so" ]
40
41
41
42
42
- def test_meta_class ():
43
- Cadet .cadet_path = full_path_dll
44
- assert Cadet .use_dll
43
+ def test_dll_runner_attrs ():
44
+ cadet = Cadet (full_path_dll .parent .parent )
45
+ cadet_runner = cadet ._cadet_dll_runner
46
+ assert re .match ("\d\.\d\.\d" , cadet_runner .cadet_version )
47
+ assert isinstance (cadet_runner .cadet_branch , str )
48
+ assert isinstance (cadet_runner .cadet_build_type , str | None )
49
+ assert isinstance (cadet_runner .cadet_commit_hash , str )
50
+ assert isinstance (cadet_runner .cadet_path , str | os .PathLike )
45
51
46
- # With a path set in the meta class, the sim instance should not autodetect and use the meta class cadet path
47
- sim = Cadet ()
48
- assert sim .use_dll
49
- assert sim .install_path == install_path_dll
50
- assert sim .cadet_dll_path .parent .parent == install_path_dll
51
- assert sim .cadet_cli_path .parent .parent == install_path_dll
52
52
53
- # With an install path given, the sim instance should use the given install path
54
- sim = Cadet (install_path = install_path_conda )
55
- assert sim .install_path == install_path_conda
56
- assert sim .cadet_dll_path .parent .parent == install_path_conda
57
- assert sim .cadet_cli_path .parent .parent == install_path_conda
53
+ def test_cli_runner_attrs ():
54
+ cadet = Cadet (full_path_dll .parent .parent )
55
+ cadet_runner = cadet ._cadet_cli_runner
56
+ assert re .match ("\d\.\d\.\d" , cadet_runner .cadet_version )
57
+ assert isinstance (cadet_runner .cadet_branch , str )
58
+ assert isinstance (cadet_runner .cadet_build_type , str | None )
59
+ assert isinstance (cadet_runner .cadet_commit_hash , str )
60
+ assert isinstance (cadet_runner .cadet_path , str | os .PathLike )
61
+
62
+
63
+ if __name__ == '__main__' :
64
+ pytest .main (["test_install_path_settings.py" ])
0 commit comments