Migrate pytest configurations to pyproject.toml #725
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
This PR moves pytest configurations (actually some pytest options) to
pyproject.toml
.Motivation:
Let's say I'm working on the
Figure.text()
function, and I want to run thepygmt/tests/test_text.py
locally to make sure that my changes work. I should use the long command:but sometimes (very often) I just run
pytest
without any options:As I don't give the
--verbose --mpl --mpl-results-path=results --doctest-modules
option,pytest
doesn't do the image comparisons at all, and it reports that all tests pass. It often confuses me a lot before I realize that I missed the necessary options.With this PR,
pytest
reads configurations frompyproject.toml
and adds the necessary options automatically. So that the short commandpytest pygmt/tests/test_text.py
always do the image comparisons and doctests.Pros:
Cons:
pyproject.toml
support needs pytest v6.0 (released on 2020-07-28). Note that Anaconda Python 3.7 ships pytest 6.1.1, while Anaconda Python 3.6 ships pytest 5.4.3. But we have dropped Python 3.6 recently. So it won't be a big issue, especially thatpytest
is only used when developing pygmt.pytest --mpl-generate-path=baseline pygmt/tests/test_text.py
, and it gives an warningUserWarning: Ignoring --mpl-result-path since --mpl-generate-path is set
. The warning is acceptable to me, and we are also trying our best to avoid storing baseline images in the repository. So I think it won't be a big issue.Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Notes
/format
in the first line of a comment to lint the code automatically