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.importorskip for sphinx_gallery test #1525

Merged
merged 4 commits into from
Sep 19, 2021

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Sep 19, 2021

Description of proposed changes

Scratching my recent code coverage itch 😄 This PR completes code coverage on the sphinx_gallery.py file which had the except ImportError: figure_rst = None lines not covered by Continuous Integration tests. Fun fact: git blame shows that these two lines go way back to 2019 (e9929a8/#268).

image

Specifically, it removes the try-except block in both pygmt/sphinx_gallery.py and pygmt/tests/test_sphinx_gallery.py, and uses pytest.importorskip instead (if someone does want to run the test but doesn't have sphinx-gallery installed). To be honest, most users probably won't be doing from pygmt.sphinx_gallery import PyGMTScraper anyway, so this is just a backend maintenance refactor.

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

Completes code coverage of the sphinx_gallery.py
file which had the `except ImportError: figure_rst = None`
lines not covered by Continuous Integration tests.
@weiji14 weiji14 added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Sep 19, 2021
@weiji14 weiji14 added this to the 0.5.0 milestone Sep 19, 2021
@weiji14 weiji14 self-assigned this Sep 19, 2021
Need to have pytest.importorskip run before importing
PyGMTScrapper.
@weiji14 weiji14 marked this pull request as ready for review September 19, 2021 02:18
Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Sep 19, 2021
@weiji14 weiji14 merged commit e50ae3f into main Sep 19, 2021
@weiji14 weiji14 deleted the refactor/sphinx-gallery-loading branch September 19, 2021 18:55
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Sep 19, 2021
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…1525)

Completes code coverage of the sphinx_gallery.py
file which had the `except ImportError: figure_rst = None`
lines not covered by Continuous Integration tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
No open projects
Release v0.5.x
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

3 participants