Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pytest-doctestplus to skip some inline doctests #1790

Merged
merged 4 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 14 additions & 2 deletions 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 @@ -36,7 +37,18 @@ test:
@echo ""
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
@echo ""
cd $(TESTDIR); PYGMT_USE_EXTERNAL_DISPLAY="false" pytest $(PYTEST_COV_ARGS) $(PROJECT)
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 ""
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
@echo ""
cd $(TESTDIR); PYGMT_USE_EXTERNAL_DISPLAY="false" pytest $(PYTEST_COV_ARGS) --doctest-modules $(PROJECT)
cp $(TESTDIR)/coverage.xml .
cp -r $(TESTDIR)/htmlcov .
rm -r $(TESTDIR)
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ omit = ["*/tests/*", "*pygmt/__init__.py"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--verbose --durations=0 --durations-min=0.2 --doctest-modules --mpl --mpl-results-path=results"
addopts = "--verbose --durations=0 --durations-min=0.2 --mpl --mpl-results-path=results"

[tool.isort]
profile = "black"
Expand Down