Repository navigation
g.gisenv: Add pytest test suite - #7803
Merged
Merged
Conversation
g.gisenv had no test coverage. Add tests/g_gisenv_test.py covering get/set/unset, case-insensitive variable names, the empty-value-unsets shortcut, protected variables (GISDBASE, LOCATION_NAME, MAPSET) being a no-op instead of failing, plain vs. shell-quoted print-all output, and the separate gisrc vs. store=mapset namespaces. Adds a local conftest.py with session/tools fixtures, following the pattern used in raster/conftest.py. AI assistance (Claude) was used to draft and verify these tests.
ninsbl
requested changes
Aug 5, 2026
ninsbl
left a comment
Member
There was a problem hiding this comment.
Looks in general good to me. One comment regarding the test of where the variable is stored. That may also be relevant to check storage for the gisrc case...
Address review feedback on the pytest suite: the store=mapset test only checked round-trip behavior through get=, not that the variable was actually written to disk. Add two tests that check the files directly with pathlib: - test_set_stores_variable_in_gisrc_file: the default store=gisrc writes into the session's gisrc file (session.env["GISRC"]). - test_set_store_mapset_stores_variable_in_var_file: store=mapset writes into <gisdbase>/<location>/<mapset>/VAR. Keeps the existing test_store_mapset_is_separate_from_gisrc, which checks the behavioral contract via get= and is complementary to the new on-disk checks.
Contributor
Author
|
@ninsbl Good catch; pushed a fix. Added two tests that check the files directly with |
Contributor
Author
|
@ninsbl ready for merge. |
Contributor
Author
|
@echoix can you check? |
echoix
approved these changes
Aug 8, 2026
echoix
left a comment
Member
There was a problem hiding this comment.
I have nothing to say after a quick read
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
g.gisenvhad no test coverage. This adds a pytest suite (tests/g_gisenv_test.py,tests/conftest.py) covering:MAPSET)unset=unset=removes a variableGISDBASE,LOCATION_NAME,MAPSET) warns but is a no-op instead of failing-n) vs. shell-quoted (-s) print-all outputstore=mapsetand the defaultgisrcstore are separate namespaces11 tests total.
general/has no sharedconftest.pyyet, so this adds a local one withsession/toolsfixtures, following the same pattern asraster/conftest.py'ssession_toolsfixture.Testing
Ran the suite against a real
main-branch GRASS session (osgeo/grass-gis:main-alpineDocker image) — all 11 tests pass. Caught and fixed a bug in my own test along the way: an early version of the separator test split the output on/, which broke becauseGISDBASEpaths contain/themselves. Checked formatting/lint with the pinnedruffversion (v0.15.17).AI disclosure
I used AI assistance (Claude) to draft and verify these tests, then reviewed and tested them myself as described above.