diff --git a/autotest/pytest.ini b/autotest/pytest.ini index 93b6f6d..73fd077 100644 --- a/autotest/pytest.ini +++ b/autotest/pytest.ini @@ -4,5 +4,5 @@ python_files = test_*.py *_test*.py markers = - slow: tests that don't complete in a few seconds + slow: tests not completing in a few seconds meta: run by other tests (e.g. testing fixtures) \ No newline at end of file diff --git a/autotest/test_executables.py b/autotest/test_executables.py index ed2369b..7d55a27 100644 --- a/autotest/test_executables.py +++ b/autotest/test_executables.py @@ -6,7 +6,7 @@ import pytest from modflow_devtools.executables import Executables -from modflow_devtools.misc import get_suffixes, add_sys_path +from modflow_devtools.misc import add_sys_path, get_suffixes ext, _ = get_suffixes(sys.platform) exe_stem = "pytest" @@ -24,15 +24,3 @@ def exes(): def test_access(exes): # support both attribute and dictionary style access assert exes.pytest == exes["pytest"] == exe_path - - -def test_get_version(exes): - ver_str = Executables.get_version(exes.pytest) - version = ( - subprocess.check_output([f"{exes.pytest}", "-v"]) - .decode("utf-8") - .split(":")[1] - .strip() - ) - assert ver_str == version - assert int(ver_str[0].split(".")[0]) >= 6 diff --git a/autotest/test_fixtures.py b/autotest/test_fixtures.py index 32d0f46..f959d0c 100644 --- a/autotest/test_fixtures.py +++ b/autotest/test_fixtures.py @@ -139,7 +139,7 @@ def test_keep_class_scoped_tmpdir(tmp_path, arg): TestKeepClassScopedTmpdirInner.test_keep_class_scoped_tmpdir_inner.__name__, "-M", "test_keep", - "-K", + arg, tmp_path, ] assert pytest.main(args) == ExitCode.OK @@ -160,19 +160,14 @@ def test_keep_module_scoped_tmpdir(tmp_path, arg): test_keep_module_scoped_tmpdir_inner.__name__, "-M", "test_keep", - "-K", + arg, tmp_path, ] assert pytest.main(args) == ExitCode.OK this_path = Path(__file__) keep_path = ( - tmp_path - / f"{str(this_path.parent.parent.name)}.{str(this_path.parent.name)}.{str(this_path.stem)}0" + tmp_path / f"{str(this_path.parent.name)}.{str(this_path.stem)}0" ) - from pprint import pprint - - print(keep_path) - pprint(list(keep_path.glob("*"))) assert test_keep_fname in [f.name for f in keep_path.glob("*")] @@ -186,7 +181,7 @@ def test_keep_session_scoped_tmpdir(tmp_path, arg, request): test_keep_session_scoped_tmpdir_inner.__name__, "-M", "test_keep", - "-K", + arg, tmp_path, ] assert pytest.main(args) == ExitCode.OK diff --git a/autotest/test_zip.py b/autotest/test_zip.py index bc72ef2..070b9c4 100644 --- a/autotest/test_zip.py +++ b/autotest/test_zip.py @@ -44,7 +44,7 @@ def empty_archive(module_tmpdir) -> Path: path = module_tmpdir / "empty.zip" with open(path, "wb") as zip: zip.write(data) - return path + yield path def test_extractall_empty(empty_archive, function_tmpdir): @@ -61,7 +61,7 @@ def archive(module_tmpdir) -> Path: zip = MFZipFile(zip_path.name, "w") zip.write(exe_path.name, compress_type=zipfile.ZIP_DEFLATED) zip.close() - return zip_path + yield zip_path @pytest.mark.parametrize("mf", [True, False]) diff --git a/docs/md/executables.md b/docs/md/executables.md index d235cc5..cfc8d79 100644 --- a/docs/md/executables.md +++ b/docs/md/executables.md @@ -29,14 +29,3 @@ def test_targets(targets): # attribute- and dictionary-style access is supported assert targets["mf6"] == targets.mf6 ``` - -There is also a convenience function for getting a program's version string. The function will automatically strip the program name from the output (assumed delimited with `:`). - -```python -import subprocess - -def test_executables_version(targets): - # returns e.g. '6.4.1 Release 12/09/2022' - assert targets.get_version(targets.mf6) == \ - subprocess.check_output([f"{targets.mf6}", "-v"]).decode('utf-8').strip().split(":")[1].strip() -``` diff --git a/modflow_devtools/executables.py b/modflow_devtools/executables.py index 28c966d..9ec0370 100644 --- a/modflow_devtools/executables.py +++ b/modflow_devtools/executables.py @@ -1,10 +1,6 @@ -import sys -from os import PathLike from pathlib import Path from types import SimpleNamespace -from typing import Dict, Optional - -from modflow_devtools.misc import get_suffixes, run_cmd +from typing import Dict class Executables(SimpleNamespace): @@ -27,14 +23,3 @@ def as_dict(self) -> Dict[str, Path]: """ return self.__dict__.copy() - - @staticmethod - def get_version(path: PathLike = None, flag: str = "-v") -> Optional[str]: - """Get an executable's version string.""" - - out, err, ret = run_cmd(str(path), flag) - if ret == 0: - out = "".join(out).strip() - return out.split(":")[1].strip() - else: - return None diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 2d20b03..0000000 --- a/pytest.ini +++ /dev/null @@ -1,8 +0,0 @@ -[pytest] -addopts = -ra --color=yes -python_files = - test_*.py - *_test*.py -markers = - slow: "tests that don't complete in a few seconds" - meta: "tests run by other tests (e.g. to test fixtures)" \ No newline at end of file