Skip to content

Commit

Permalink
Use pytest-doctestplus to skip some inline doctests (#1790)
Browse files Browse the repository at this point in the history
* Use pytest-doctestplus to skip some inline doctests
* Install pytest-doctestplus in workflows
* Add the fulltest target to run all tests, including all doctests
  • Loading branch information
seisman authored Mar 8, 2022
1 parent d4e3758 commit d24c0a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
pandas xarray netCDF4 packaging \
${{ matrix.optional-packages }} \
dvc make pytest>=6.0 \
pytest-cov pytest-mpl sphinx-gallery tomli
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery tomli
# Show installed pkg information for postmortem diagnostic
- name: List installed packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
pip install --pre --prefer-binary \
numpy pandas xarray netCDF4 packaging \
dvc ipython 'pytest>=6.0' pytest-cov \
pytest-mpl sphinx-gallery tomli
pytest-doctestplus pytest-mpl sphinx-gallery tomli
# Pull baseline image data from dvc remote (DAGsHub)
- name: Pull baseline image data from dvc remote
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ help:
@echo ""
@echo " install install in editable mode"
@echo " package build source and wheel distributions"
@echo " test run the test suite (including doctests) and report coverage"
@echo " test run the test suite (including some doctests) and report coverage"
@echo " fulltest run the test suite (including all doctests) and report coverage"
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
@echo " check run code style and quality checks (black, blackdoc, docformatter, flake8 and isort)"
@echo " lint run pylint for a deeper (and slower) quality check"
Expand All @@ -31,6 +32,17 @@ package:
python setup.py sdist bdist_wheel

test:
# Run a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
@echo ""
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
@echo ""
cd $(TESTDIR); PYGMT_USE_EXTERNAL_DISPLAY="false" pytest $(PYTEST_COV_ARGS) --doctest-plus $(PROJECT)
cp $(TESTDIR)/coverage.xml .
cp -r $(TESTDIR)/htmlcov .
rm -r $(TESTDIR)

fulltest:
# Run a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
@echo ""
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- myst-parser
- pylint
- pytest-cov
- pytest-doctestplus
- pytest-mpl
- pytest>=6.0
- sphinx
Expand Down
9 changes: 4 additions & 5 deletions pygmt/src/grdlandmask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
grdlandmask - Create a "wet-dry" mask grid from shoreline data base
"""

from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
Expand All @@ -13,6 +12,8 @@
)
from pygmt.io import load_dataarray

__doctest_skip__ = ["grdlandmask"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -95,12 +96,10 @@ def grdlandmask(**kwargs):
Example
-------
>>> import pygmt # doctest: +SKIP
>>> import pygmt
>>> # Create a landmask grid with an x-range of 125 to 130,
>>> # and a y-range of 30 to 35
>>> landmask = pygmt.grdlandmask(
... spacing=1, region=[125, 130, 30, 35]
... ) # doctest: +SKIP
>>> landmask = pygmt.grdlandmask(spacing=1, region=[125, 130, 30, 35])
"""
if "I" not in kwargs or "R" not in kwargs:
raise GMTInvalidInput("Both 'region' and 'spacing' must be specified.")
Expand Down

0 comments on commit d24c0a6

Please sign in to comment.