Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: move get_version fn to conftest.py from devtools #1438

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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