Skip to content

v.random: migrate tests from gunittest to pytest - #7822

Merged
petrasovaa merged 10 commits into
OSGeo:mainfrom
Valyrian-Code:v.random-pytest
Sep 15, 2026
Merged

petrasovaa merged 10 commits into
OSGeo:mainfrom
Valyrian-Code:v.random-pytest

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

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

The new vector/v.random/tests/v_random_test.py keeps the same three cases as the old testsuite/test_v_random.py:

  • the requested number of points is created
  • the -z flag with zmin/zmax produces a 3D point map
  • restrict= keeps every point inside the given area (clipping by that area removes none)

To avoid depending on the NC sample dataset, the nc_state vector is replaced with a synthetic area created from a sub-region via v.in.region, and topology is read via v.info -t format=json. Verified locally on GRASS 8.5, all three pass.

Cover the same three cases as the gunittest testsuite: the requested number of
points is created, the -z flag with zmin/zmax produces a 3D map, and restrict=
keeps points inside a given area. Replace the nc_state sample vector with a
synthetic area (v.in.region on a sub-region) so the test needs no dataset, and
read topology via v.info -t format=json.
Copilot AI lite review requested due to automatic review settings August 11, 2026 16:28
@github-actions github-actions Bot added vector Related to vector 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.

Pull request overview

This PR migrates v.random’s test coverage from legacy gunittest (testsuite/) to pytest (tests/), aligning v.random with the project’s ongoing move toward pytest-based testing.

Changes:

  • Remove the existing gunittest-based test module for v.random.
  • Add a new pytest-based test module which creates a synthetic restrict area using v.in.region and validates point count, 3D output, and restrict= behavior.

Reviewed changes

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

File Description
vector/v.random/testsuite/test_v_random.py Removes the legacy gunittest-based tests.
vector/v.random/tests/v_random_test.py Adds pytest equivalents using a temporary GRASS project and synthetic restrict area.

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

Comment thread vector/v.random/tests/v_random_test.py Resolved
Comment thread vector/v.random/tests/v_random_test.py Resolved
Valyrian-Code and others added 3 commits August 11, 2026 22:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The topology checks in test_points_are_3d were dedented to module level,
where flake8 rightly flags tools as undefined (F821). Indent them back into
the test.
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Dropped overwrite=True from the fixture here too, same reason, the fresh project per test makes it unnecessary.

Comment thread vector/v.random/tests/v_random_test.py Resolved
Comment thread vector/v.random/tests/v_random_test.py Resolved
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Added the SPDX-License-Identifier line, thanks for the pointer.

@echoix echoix added the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Sep 5, 2026
# Conflicts:
#	vector/v.random/testsuite/test_v_random.py
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Merged main and resolved a conflict here too, same root cause as #7780: the SPDX header update from #7756 landed on the old testsuite file this PR removes.

@echoix echoix removed the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Sep 12, 2026
@echoix
echoix requested a review from petrasovaa September 12, 2026 18:33
ToolResult.__getitem__ proxies to the parsed JSON, so subscripting the
result directly is equivalent. Applies the same change to the other three
calls, as asked in review.
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Sorry, I missed the "and elsewhere" and only kept your line. Dropped .json from the other three calls now, tests still pass.

@petrasovaa
petrasovaa merged commit 8843f13 into OSGeo:main Sep 15, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Sep 15, 2026
@Valyrian-Code
Valyrian-Code deleted the v.random-pytest branch September 17, 2026 04:31
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 tests Related to Test Suite vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants