r.random.cells: migrate tests from gunittest to pytest - #7893
r.random.cells: migrate tests from gunittest to pytest#7893Valyrian-Code wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Migrates r.random.cells test coverage from the legacy gunittest harness to pytest, preserving the three existing behavioral cases and seed-based expectations.
Changes:
- Removes the
gunittest-based test file undertestsuite/. - Adds a new
pytesttest module using an isolated GRASS project/session fixture. - Re-implements the same three assertions using
r.univarJSON output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| raster/r.random.cells/testsuite/test_random_cells.py | Removes the previous gunittest tests being migrated. |
| raster/r.random.cells/tests/r_random_cells_test.py | Adds pytest equivalents using grass.script + Tools and r.univar JSON assertions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @pytest.fixture | ||
| def session(tmp_path): | ||
| """An isolated GRASS session with the region r.random.cells fills.""" | ||
| project = tmp_path / "r_random_cells_project" | ||
| gs.create_project(project) | ||
| with gs.setup.init(project, env=os.environ.copy()) as session: | ||
| tools = Tools(session=session) | ||
| tools.g_region(n=20, s=10, e=60, w=40, res=2) | ||
| yield session |
| @@ -0,0 +1,62 @@ | |||
| # SPDX-License-Identifier: GPL-2.0-or-later | |||
|
|
||
|
|
||
| @pytest.fixture | ||
| def session(tmp_path): |
|
@wenzeslaus Is there a known pattern for gunittest "assertRasterFitsUnivar" to pytest? Otherwise, we would be recopying the assertions but we are loosing the fact that these multiple independant asserts mean something when together (so the pattern will probably diverge accross files in the future). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks for the review. A few notes:
|
Migrates the r.random.cells testsuite from gunittest to pytest, continuing the one-at-a-time migrations from #7635/#7675/#7780.
Keeps the same three cases and the same seed=100, so the reproduced values match the original test:
Verified locally, all three pass.