FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

r.support: migrate tests from gunittest to pytest by Valyrian-Code · Pull Request #7821 · OSGeo/grass · GitHub

/ grass Public

r.support: migrate tests from gunittest to pytest - #7821

Merged
echoix merged 5 commits into
OSGeo:mainfrom
Valyrian-Code:r.support-pytest
Aug 28, 2026
Merged

r.support: migrate tests from gunittest to pytest#7821
echoix merged 5 commits into
OSGeo:mainfrom
Valyrian-Code:r.support-pytest

Conversation

Copy link
Copy Markdown
Contributor

Migrates r.support's tests from gunittest to pytest, part of the effort to support writing tests with pytest.

The new raster/r.support/tests/r_support_test.py keeps the same four cases as the old testsuite/test_r_support.py:

  • setting and removing a semantic label in one call fails
  • an over-long semantic label is rejected
  • r.support assigns the semantic label to the map
  • the -b flag clears a previously assigned label

It uses a tmp_path session fixture with a synthetic single-cell raster, and reads the label back via r.info format=json rather than the ctypes grass.lib bindings the old test used. Verified locally on GRASS 8.5, all four pass.

Cover the same four cases as the gunittest testsuite: setting and removing a
semantic label at once fails, an over-long label is rejected, r.support
assigns the semantic label, and the -b flag clears it. Uses a tmp_path session
fixture with a synthetic raster and reads the label back via r.info
format=json instead of the ctypes library bindings.
Copilot AI lite review requested due to automatic review settings August 11, 2026 16:26
github-actions Bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR migrates r.support’s semantic label handling tests from the legacy gunittest framework to pytest, aligning the module with the project-wide move toward pytest-based testing.

Changes:

  • Remove the gunittest-based test file for r.support.
  • Add a new pytest test module which creates a temporary GRASS project/session and validates semantic label set/clear behavior via r.info format=json.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
raster/r.support/testsuite/test_r_support.py Removes the previous gunittest-based semantic label tests.
raster/r.support/tests/r_support_test.py Adds pytest-based semantic label tests using a tmp_path-backed session and JSON metadata checks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Valyrian-Code and others added 3 commits August 11, 2026 22:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
test_semantic_label_and_removal_are_exclusive used tools without creating
it in the test, which flake8 flags as F821 and which raises NameError at
run time.

Copy link
Copy Markdown
Contributor Author

Dropped overwrite=True from the fixture, it was not needed. The fixture creates a fresh project each time, so there is no map to collide with.

Copy link
Copy Markdown
Contributor Author

Added the SPDX-License-Identifier header here too, same tip from #7822.

ninsbl commented Aug 27, 2026

Copy link
Copy Markdown
Member

While this technically ports the test, the test itself lacks tests for a lot of functionality, see e.g.:
https://grass.osgeo.org/grass-stable/manuals/r.support.html
Would be great if you could increase the test coverage here, while you are at it...

echoix commented Aug 27, 2026

Copy link
Copy Markdown
Member

While this technically ports the test, the test itself lacks tests for a lot of functionality, see e.g.:

https://grass.osgeo.org/grass-stable/manuals/r.support.html

Would be great if you could increase the test coverage here, while you are at it...

I'd still merge the existing tests as is and review what changed after. But it's personal preference matter, as it makes less to check than a whole new file to add

Copy link
Copy Markdown
Contributor Author

Good point, thanks. Let's go with your suggestion, merge this as is and I'll open a follow-up PR that adds coverage for the other options (title, history, units, vdatum, source1/source2, description, loadhistory/savehistory).

echoix merged commit bde472e into OSGeo:main Aug 28, 2026
26 checks passed
github-actions Bot added this to the 8.6.0 milestone Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL