forked from MODFLOW-USGS/modflow-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move tests to autotest/, remove BIN_PATH testing env var, simplify te…
…sts, add aliases, update docs
- Loading branch information
Showing
21 changed files
with
223 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[pytest] | ||
addopts = -ra --color=yes | ||
python_files = | ||
test_*.py | ||
*_test*.py | ||
markers = | ||
slow: tests that don't complete in a few seconds | ||
meta: run by other tests (e.g. testing fixtures) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
modflow_devtools/test/test_download.py → autotest/test_download.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
from shutil import which | ||
|
||
import pytest | ||
|
||
from modflow_devtools.executables import Executables | ||
from modflow_devtools.misc import get_suffixes, set_path | ||
|
||
ext, _ = get_suffixes(sys.platform) | ||
exe_stem = "pytest" | ||
exe_path = Path(which(exe_stem)) | ||
bin_path = exe_path.parent | ||
exe = f"{exe_stem}{ext}" | ||
|
||
|
||
@pytest.fixture | ||
def exes(): | ||
with set_path(bin_path): | ||
yield Executables(**{exe_stem: bin_path / exe}) | ||
|
||
|
||
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 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from os import environ | ||
from platform import python_version, system | ||
from shutil import which | ||
|
||
from packaging.version import Version | ||
|
||
from modflow_devtools.markers import * | ||
|
||
exe = "pytest" | ||
|
||
|
||
@requires_exe(exe) | ||
def test_require_exe(): | ||
assert which(exe) | ||
require_exe(exe) | ||
require_program(exe) | ||
|
||
|
||
exes = [exe, "python"] | ||
|
||
|
||
@require_exe(*exes) | ||
def test_require_exe_multiple(): | ||
assert all(which(exe) for exe in exes) | ||
|
||
|
||
@requires_pkg("pytest") | ||
def test_requires_pkg(): | ||
import numpy | ||
|
||
assert numpy is not None | ||
|
||
|
||
@requires_pkg("pytest", "pluggy") | ||
def test_requires_pkg_multiple(): | ||
import pluggy | ||
import pytest | ||
|
||
assert pluggy is not None and pytest is not None | ||
|
||
|
||
@requires_platform("Windows") | ||
def test_requires_platform(): | ||
assert system() == "Windows" | ||
|
||
|
||
@excludes_platform("Darwin", ci_only=True) | ||
def test_requires_platform_ci_only(): | ||
if "CI" in environ: | ||
assert system() != "Darwin" | ||
|
||
|
||
py_ver = python_version() | ||
|
||
|
||
@pytest.mark.parametrize("version", ["3.12", "3.11"]) | ||
def test_requires_python(version): | ||
if Version(py_ver) >= Version(version): | ||
assert requires_python(version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from platform import system | ||
|
||
import pytest | ||
|
||
from modflow_devtools.ostags import ( | ||
OSTag, | ||
get_binary_suffixes, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.