Skip to content

Commit c640e13

Browse files
authored
test: move get_version fn to conftest.py from devtools (#1438)
1 parent c622cca commit c640e13

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

autotest/conftest.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,31 @@
22
import sys
33
from pathlib import Path
44
from os import PathLike
5-
from typing import Dict
5+
from typing import Dict, Optional
66

77
import pytest
88
from modflow_devtools.executables import Executables, get_suffixes
9+
from modflow_devtools.misc import run_cmd
910

1011
pytest_plugins = ["modflow_devtools.fixtures"]
1112
project_root_path = Path(__file__).resolve().parent.parent
1213

1314

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+
1424
def should_compare(
1525
test: str, comparisons: dict, executables: Executables
1626
) -> bool:
1727
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)
2230
print(f"MODFLOW 6 development version: {dev_ver}")
2331
print(f"MODFLOW 6 regression version: {reg_ver}")
2432
excluded = list(comparisons[test])
@@ -93,7 +101,7 @@ def original_regression(request) -> bool:
93101

94102
@pytest.fixture(scope="session")
95103
def markers(pytestconfig) -> str:
96-
return pytestconfig.getoption('-m')
104+
return pytestconfig.getoption("-m")
97105

98106

99107
def pytest_addoption(parser):
@@ -104,10 +112,10 @@ def pytest_addoption(parser):
104112
help="TODO",
105113
)
106114
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",
111119
)
112120

113121

0 commit comments

Comments
 (0)