Skip to content

r.cross: migrate tests from gunittest to pytest - #7635

Merged
echoix merged 7 commits into
OSGeo:mainfrom
Valyrian-Code:r.cross-pytest
Jul 17, 2026
Merged

r.cross: migrate tests from gunittest to pytest#7635
echoix merged 7 commits into
OSGeo:mainfrom
Valyrian-Code:r.cross-pytest

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

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

The new raster/r.cross/tests/test_r_cross.py preserves the coverage of the old testsuite/test_cross.py:

  • basic cross product of two synthetic 3x3 rasters, giving categories 0..8 with no NULLs
  • the -z flag case, where combinations containing NULL are dropped, giving categories 0..5 with NULLs in the output

It uses a tmp_path session fixture (gs.create_project + gs.setup.init) with synthetic rasters built via r.mapcalc, runs the tool through grass.tools.Tools, and asserts on r.describe format=json. The old gunittest testsuite is removed.

Verified locally on GRASS 8.5, both tests pass. Happy to apply the same pattern to other modules if this looks like a good template.

Replace the gunittest testsuite with a pytest module covering the same
behavior: the basic cross product (categories 0..8, no NULLs) and the -z
flag case (NULL combinations dropped, categories 0..5, output has NULLs).
It uses a tmp_path session fixture with synthetic 3x3 rasters and the
grass.tools API.
Copilot AI review requested due to automatic review settings July 4, 2026 05:10

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Jul 4, 2026
echoix
echoix previously approved these changes Jul 10, 2026
Comment thread raster/r.cross/tests/test_r_cross.py
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Good tip, thanks. I kept it one to one with the old test here, and the single call form would make a nice follow-up cleanup.

@echoix

echoix commented Jul 10, 2026

Copy link
Copy Markdown
Member

Just so you know, be nice with CI next week. There’s the community meeting where we meet up in person (arriving tomorrow), and all in the same time zone. We’ll need all available capacity, it will be our bottleneck. If there’s a specific reason to update a PR (because of semantic conflicts), it’s fine, otherwise, only when pushing actual changes.

@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Just so you know, be nice with CI next week. There’s the community meeting where we meet up in person (arriving tomorrow), and all in the same time zone. We’ll need all available capacity, it will be our bottleneck. If there’s a specific reason to update a PR (because of semantic conflicts), it’s fine, otherwise, only when pushing actual changes.

Understood, thanks for the heads up. I will leave the open PRs as they are and only push when there is an actual change. Enjoy the community meeting!

@echoix

echoix commented Jul 10, 2026

Copy link
Copy Markdown
Member

If you have some free time during the UTC+2 time zone, there’s some ways to participate remotely too! https://grasswiki.osgeo.org/wiki/GRASS_Community_Meeting_San_Michele_2026

We can always take a little chat to discuss more advanced topics that need coordination, without having to wait back and forth too much

@echoix

echoix commented Jul 10, 2026

Copy link
Copy Markdown
Member

From past years’ experience, we do get overwhelmed with notifications on GitHub, mixed with our work, helping others, and the other discussions, so you might not be forgotten if we don’t respond enough

@Valyrian-Code

Valyrian-Code commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the invitation, I would really like to join remotely. I am in IST for now, so the UTC+2 afternoon lines up with my evening, and I will follow the wiki schedule. A chat about topics that need coordination sounds great whenever it suits you.

Also completely understood about the notifications, no rush from my side ever. A small piece of news: I was selected for the Apple Developer Academy in Naples, a nine month program starting this September, so I will actually be in Italy and in your time zone soon. Maybe that makes a future call or meetup easier.

Enjoy San Michele!

@echoix

echoix commented Jul 12, 2026

Copy link
Copy Markdown
Member

I'm rerunning the failed job, the fix for what we saw is being submitted as I write, and will be fixed now. This PR was simple to review, as it was small, isolated, and took a gunittest that didn't need the test dataset to run. So, if you want to find another one similar to that, I'd be glad to review one at a time (don't overwhelm us though)

@echoix
echoix enabled auto-merge (squash) July 12, 2026 07:42
Comment thread raster/r.cross/tests/test_r_cross.py Outdated
Comment thread raster/r.cross/tests/test_r_cross.py Outdated
@echoix
echoix disabled auto-merge July 12, 2026 08:11
Comment thread raster/r.cross/tests/test_r_cross.py Outdated
Comment thread raster/r.cross/tests/test_r_cross.py Outdated
Comment thread raster/r.cross/tests/test_r_cross.py Outdated
Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works for me locally. I'm leaving the name as is - We are currently allowing both names (test_x and x_test with x_test being the preference at some point).

@echoix

echoix commented Jul 15, 2026

Copy link
Copy Markdown
Member

The still failing windows test of v.class was recently fixed in #7692, the branch needs to get updated again

@echoix
echoix merged commit cb04122 into OSGeo:main Jul 17, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Jul 17, 2026
@Valyrian-Code
Valyrian-Code deleted the r.cross-pytest branch July 18, 2026 18:08
@Valyrian-Code

Valyrian-Code commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@echoix & @wenzeslaus Thanks for pushing this through, and for updating the branch after the Windows fix.

~ Appreciate the guidance along the way. ✨

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