2
2
import sys
3
3
from pathlib import Path
4
4
from os import PathLike
5
- from typing import Dict
5
+ from typing import Dict , Optional
6
6
7
7
import pytest
8
8
from modflow_devtools .executables import Executables , get_suffixes
9
+ from modflow_devtools .misc import run_cmd
9
10
10
11
pytest_plugins = ["modflow_devtools.fixtures" ]
11
12
project_root_path = Path (__file__ ).resolve ().parent .parent
12
13
13
14
15
+ def get_version (path : PathLike = None , flag : str = "-v" ) -> Optional [str ]:
16
+ out , err , ret = run_cmd (str (path ), flag )
17
+ if ret == 0 :
18
+ out = "" .join (out ).strip ()
19
+ return out .split (":" )[1 ].strip ().split (" " )[0 ]
20
+ else :
21
+ raise ValueError (f"Failed to parse version from:\n { out + err } " )
22
+
23
+
14
24
def should_compare (
15
25
test : str , comparisons : dict , executables : Executables
16
26
) -> bool :
17
27
if test in comparisons .keys ():
18
- dev_ver = Executables .get_version (path = executables .mf6 ).split (" " )[0 ]
19
- reg_ver = Executables .get_version (
20
- path = executables .mf6_regression
21
- ).split (" " )[0 ]
28
+ dev_ver = get_version (path = executables .mf6 )
29
+ reg_ver = get_version (path = executables .mf6_regression )
22
30
print (f"MODFLOW 6 development version: { dev_ver } " )
23
31
print (f"MODFLOW 6 regression version: { reg_ver } " )
24
32
excluded = list (comparisons [test ])
@@ -93,7 +101,7 @@ def original_regression(request) -> bool:
93
101
94
102
@pytest .fixture (scope = "session" )
95
103
def markers (pytestconfig ) -> str :
96
- return pytestconfig .getoption ('-m' )
104
+ return pytestconfig .getoption ("-m" )
97
105
98
106
99
107
def pytest_addoption (parser ):
@@ -104,10 +112,10 @@ def pytest_addoption(parser):
104
112
help = "TODO" ,
105
113
)
106
114
parser .addoption (
107
- "--parallel" ,
108
- action = "store_true" ,
109
- default = False ,
110
- help = "include parallel test cases"
115
+ "--parallel" ,
116
+ action = "store_true" ,
117
+ default = False ,
118
+ help = "include parallel test cases" ,
111
119
)
112
120
113
121
0 commit comments