Skip to content

grass.jupyter: add test for utils.py functions#7052

Closed
ayushjariyal wants to merge 5 commits intoOSGeo:mainfrom
ayushjariyal:test_for_utils
Closed

grass.jupyter: add test for utils.py functions#7052
ayushjariyal wants to merge 5 commits intoOSGeo:mainfrom
ayushjariyal:test_for_utils

Conversation

@ayushjariyal
Copy link
Contributor

I noticed that there is no test for utils.py file in grass/jupyter/test directory.
so, In this PR, I add tests for get_region and get_location_proj_string function of utils.py file.
I verify these test by locally running pytest

image

@github-actions github-actions bot added Python Related code is in Python libraries tests Related to Test Suite notebook labels Feb 7, 2026
@ayushjariyal
Copy link
Contributor Author

@petrasovaa, I am not able to change the title of this PR. could you please do that so that it can pass the test and please review this PR.

@ayushjariyal
Copy link
Contributor Author

@petrasovaa, It looks like pytest is failing because these tests require an active GRASS session. Locally they pass when run inside a GRASS session, but in CI, the session does not seem to be initialized.
Could you please let me know whether this is a CI setup issue or something caused by my changes?

@gulshan-123
Copy link
Contributor

i believe you should use something like this (see conftest.py under tests):

with gs.setup.init(project):
      ....

Basically, gs.setup.init starts the session.

Also, to check whether this succeeds or not, I run the pytest in linux terminal (not in the grass terminal).
For this, you may have to do:

make

Then note the output of ./bin.x86_64-pc-linux-gnu/grass --config python_path
export PYTHONPATH=$PYTHONPATH:<Output Of Above>

Now run pytest to see if it succeeds...

@petrasovaa petrasovaa changed the title Test: add test for utils.py funcions. grass.jupyter: add test for utils.py functions Feb 9, 2026
@petrasovaa
Copy link
Contributor

@ayushjariyal this is not going anywhere, you need to test locally and then open a PR.

@petrasovaa petrasovaa closed this Feb 9, 2026
@ayushjariyal
Copy link
Contributor Author

@petrasovaa, Thanks for the clarification.
You’re right — the tests depended on an existing GRASS environment. I’ll correct this by explicitly initializing and passing the session environment, test it outside the GRASS shell, and submit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries notebook Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants