зеркало из https://github.com/microsoft/torchgeo.git
Add unit tests
This commit is contained in:
Родитель
01f42ca3e7
Коммит
d3b21a7c2b
2
.flake8
2
.flake8
|
@ -17,5 +17,5 @@ exclude =
|
||||||
|
|
||||||
# Git
|
# Git
|
||||||
.git/,
|
.git/,
|
||||||
application-import-names = torchgeo
|
application-import-names = docs,tests,torchgeo
|
||||||
import-order-style = google
|
import-order-style = google
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
name: pytest
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '**.py'
|
||||||
|
- 'requirements.txt'
|
||||||
|
- '.github/workflows/pytest.yaml'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '**.py'
|
||||||
|
- 'requirements.txt'
|
||||||
|
- '.github/workflows/pytest.yaml'
|
||||||
|
jobs:
|
||||||
|
pytest:
|
||||||
|
name: pytest
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip3 install -r requirements.txt
|
||||||
|
- name: Run pytest checks
|
||||||
|
run: pytest
|
|
@ -5,6 +5,8 @@ mypy
|
||||||
opencv-python
|
opencv-python
|
||||||
pillow
|
pillow
|
||||||
pycocotools
|
pycocotools
|
||||||
|
pytest
|
||||||
|
pytest-cov
|
||||||
pytorch-sphinx-theme
|
pytorch-sphinx-theme
|
||||||
radiant-mlhub>=0.2.1
|
radiant-mlhub>=0.2.1
|
||||||
rarfile
|
rarfile
|
||||||
|
|
|
@ -30,6 +30,9 @@ install_requires =
|
||||||
python_requires = >= 3.5
|
python_requires = >= 3.5
|
||||||
packages = find:
|
packages = find:
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
include = torchgeo
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
cv4akenyacroptype =
|
cv4akenyacroptype =
|
||||||
radiant-mlhub>=0.2.1
|
radiant-mlhub>=0.2.1
|
||||||
|
|
|
@ -8,6 +8,8 @@ spack:
|
||||||
- py-mypy
|
- py-mypy
|
||||||
- py-pillow-simd
|
- py-pillow-simd
|
||||||
- py-pycocotools
|
- py-pycocotools
|
||||||
|
- py-pytest
|
||||||
|
- py-pytest-cov
|
||||||
- py-pytorch-sphinx-theme
|
- py-pytorch-sphinx-theme
|
||||||
- "py-radiant-mlhub@0.2.1:"
|
- "py-radiant-mlhub@0.2.1:"
|
||||||
- py-rarfile
|
- py-rarfile
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
from torchgeo.datasets.utils import working_dir
|
||||||
|
|
||||||
|
|
||||||
|
def test_existing_directory(tmp_path: pathlib.Path) -> None:
|
||||||
|
subdir = tmp_path / "foo" / "bar"
|
||||||
|
subdir.mkdir(parents=True)
|
||||||
|
|
||||||
|
assert subdir.exists()
|
||||||
|
|
||||||
|
with working_dir(str(subdir)):
|
||||||
|
assert subdir.cwd() == subdir
|
||||||
|
|
||||||
|
|
||||||
|
def test_nonexisting_directory(tmp_path: pathlib.Path) -> None:
|
||||||
|
subdir = tmp_path / "foo" / "bar"
|
||||||
|
|
||||||
|
assert not subdir.exists()
|
||||||
|
|
||||||
|
with working_dir(str(subdir), create=True):
|
||||||
|
assert subdir.cwd() == subdir
|
Загрузка…
Ссылка в новой задаче