Skip to content

Commit

Permalink
test: move get_version fn to conftest.py from devtools (MODFLOW-USGS#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli authored Nov 11, 2023
1 parent c622cca commit c640e13
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@
import sys
from pathlib import Path
from os import PathLike
from typing import Dict
from typing import Dict, Optional

import pytest
from modflow_devtools.executables import Executables, get_suffixes
from modflow_devtools.misc import run_cmd

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


def get_version(path: PathLike = None, flag: str = "-v") -> Optional[str]:
out, err, ret = run_cmd(str(path), flag)
if ret == 0:
out = "".join(out).strip()
return out.split(":")[1].strip().split(" ")[0]
else:
raise ValueError(f"Failed to parse version from:\n{out + err}")


def should_compare(
test: str, comparisons: dict, executables: Executables
) -> bool:
if test in comparisons.keys():
dev_ver = Executables.get_version(path=executables.mf6).split(" ")[0]
reg_ver = Executables.get_version(
path=executables.mf6_regression
).split(" ")[0]
dev_ver = get_version(path=executables.mf6)
reg_ver = get_version(path=executables.mf6_regression)
print(f"MODFLOW 6 development version: {dev_ver}")
print(f"MODFLOW 6 regression version: {reg_ver}")
excluded = list(comparisons[test])
Expand Down Expand Up @@ -93,7 +101,7 @@ def original_regression(request) -> bool:

@pytest.fixture(scope="session")
def markers(pytestconfig) -> str:
return pytestconfig.getoption('-m')
return pytestconfig.getoption("-m")


def pytest_addoption(parser):
Expand All @@ -104,10 +112,10 @@ def pytest_addoption(parser):
help="TODO",
)
parser.addoption(
"--parallel",
action="store_true",
default=False,
help="include parallel test cases"
"--parallel",
action="store_true",
default=False,
help="include parallel test cases",
)


Expand Down

0 comments on commit c640e13

Please sign in to comment.