Skip to content

Commit

Permalink
add markers for running tests that don't require gdal
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Dec 21, 2023
1 parent 3af0f90 commit 4d3f54f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ help:
.PHONY: test
test:
@echo "Running all tests"
pytest
@bash -c 'pytest'

.PHONY: test-no-gdal
test:
@echo "Running all tests"
@bash -c 'pytest -m "not requires_gdal"'

.PHONY: clean
clean:
Expand Down
12 changes: 5 additions & 7 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import pytest
from cookiecutter.utils import rmtree

from click.testing import CliRunner

import importlib

@contextmanager
def inside_dir(dirpath):
Expand Down Expand Up @@ -88,8 +85,9 @@ def test_bake_with_defaults(cookies):
def test_bake_and_run_tests(cookies):
with bake_in_temp_dir(cookies) as result:
assert result.project.isdir()
assert run_inside_dir('which python', str(result.project)) == 0
run_inside_dir('pip install -e .', str(result.project))
run_inside_dir('pytest tests', str(result.project)) == 0
assert run_inside_dir('pytest tests', str(result.project)) == 0
print("test_bake_and_run_tests path", str(result.project))


Expand All @@ -101,7 +99,7 @@ def test_bake_withspecialchars_and_run_tests(cookies):
extra_context={'full_name': 'name "quote" name', 'use_pytest': 'n'}
) as result:
assert result.project.isdir()
run_inside_dir('python setup.py test', str(result.project)) == 0
assert run_inside_dir('python setup.py test', str(result.project)) == 0


@pytest.mark.requires_gdal
Expand All @@ -112,7 +110,7 @@ def test_bake_with_apostrophe_and_run_tests(cookies):
extra_context={'full_name': "O'connor"}
) as result:
assert result.project.isdir()
run_inside_dir('pytest', str(result.project)) == 0
assert run_inside_dir('pytest', str(result.project)) == 0


# def test_bake_and_run_travis_pypi_setup(cookies):
Expand Down Expand Up @@ -208,7 +206,7 @@ def test_using_pytest(cookies):
lines = test_file_path.readlines()
assert "import pytest" in ''.join(lines)
# Test the new pytest target
run_inside_dir('pytest', str(result.project)) == 0
assert run_inside_dir('pytest', str(result.project)) == 0


@pytest.mark.parametrize("use_black,expected", [("y", True), ("n", False)])
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ deps =
install_command = python -m pip install --no-user {opts} {packages}
download = True
commands =
make test
!pypy38: make test
pypy38: make test-no-gdal
allowlist_externals =
make

0 comments on commit 4d3f54f

Please sign in to comment.