Repository navigation
Tests: add pytest-based test for rasterExists helper function - #7171
ayushjariyal wants to merge 21 commits into
Conversation
63be943 to
7df831d
Compare
|
While working on the pytest conversion, I organized the related utilities into a new directory However, the CI checks are currently failing with the following error:
It seems that the new subpackage may not be included in the installed GRASS Python package used in CI. Before proceeding further, I wanted to confirm whether introducing a separate submodule like If the separate submodule approach is acceptable, could you please suggest what changes might be needed so that I would like to follow the structure that fits best with the project. |
|
Most probably the makefiles and CMakeLists need to be adjusted in consequence. Look for the closest ones up in the folder hierarchy |
b96c294 to
6423f48
Compare
|
@echoix, @petrasovaa , Now all the checks are passed. Could you please review it now? |
wenzeslaus
left a comment
There was a problem hiding this comment.
This is a lot of code for what are basically two lines of new code. Yes, something like special set of functions to aid pytest might be needed, but let's think about this first: Raster existence check goes beyond pytest-based testing. Where it can live instead? Can the grass.gunittest code use such a function?
This is also a lot of noise compared to the resulting code. While the current code has some merit, it is nowhere close to being merged.
72d20aa to
a379acc
Compare
|
@wenzeslaus , Thanks for the feedback! I’ve updated the helper to behave as a proper pytest-style assertion by raising AssertionError instead of returning a boolean. I also renamed it to raster_exists to follow snake_case conventions. |
e53d8a4 to
b9572ad
Compare
b9572ad to
069f8b7
Compare
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
069f8b7 to
36b9f1b
Compare
|
Thank you @ayushjariyal. This was interesting discussion, but unfortunately this cannot be merged. At this point, while it makes sense, it is adding one function for what is potentially a large API, and it introduces that API (pygrass under grass). A more comprehensive analysis of how to create that API would be needed to actually merge this. Current solution is longer and much less elegant, but works: assert tools.g_findfile(element="cell", file="elevation", format="json").get("file")One possible question for a new API like this is: Should this be pytest-specific (like here), Python-level (gs.raster_exists), or tool-level (e.g. r.exists)? Anyway, this needs to be closed, the PR scope and code are fine, but we don't have the general design in which this would fit in. You (anyone) can start a discussion to develop one if the current state is not sufficient from your perspective. |
This PR introduces a pytest-based test for rasterExists and a fixture for automatic GRASS session setup.
Changes:
Testing:
GSoC 2026:
This contribution is a part of GSoC 2026 Support writing tests with pytest project.