File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import grass .script as gs
2-
3-
4- def rasterExists (map_name , env = None ):
5- """Check if a raster map exists in the given mapset."""
6- result = gs .find_file (map_name , element = "cell" , env = env )
7- return bool (result ["name" ])
1+ import grass .script as gs
2+
3+
4+ def rasterExists (map_name , env = None ):
5+ """Check if a raster map exists in the given mapset."""
6+ result = gs .find_file (map_name , element = "cell" , env = env )
7+ return bool (result ["name" ])
Original file line number Diff line number Diff line change 1- import os
2- import pytest
3- import grass .script as gs
4-
5-
6- @pytest .fixture
7- def session (tmp_path ):
8- project = tmp_path / "test_proj"
9- gs .create_project (project )
10-
11- with gs .setup .init (project , env = os .environ .copy ()) as session :
12- yield session .env
1+ import os
2+ import pytest
3+ import grass .script as gs
4+
5+
6+ @pytest .fixture
7+ def session (tmp_path ):
8+ project = tmp_path / "test_proj"
9+ gs .create_project (project )
10+
11+ with gs .setup .init (project , env = os .environ .copy ()) as session :
12+ yield session .env
Original file line number Diff line number Diff line change 1- import grass .script as gs
2- from grass .pytest .assertions import rasterExists
3-
4-
5- def test_rasterExists (session ):
6- gs .run_command ("r.mapcalc" , expression = "test_map = 1" , env = session )
7-
8- assert rasterExists ("test_map" , env = session )
9- assert not rasterExists ("missing_map" , env = session )
1+ import grass .script as gs
2+ from grass .pytest .assertions import rasterExists
3+
4+
5+ def test_rasterExists (session ):
6+ gs .run_command ("r.mapcalc" , expression = "test_map = 1" , env = session )
7+
8+ assert rasterExists ("test_map" , env = session )
9+ assert not rasterExists ("missing_map" , env = session )
You can’t perform that action at this time.
0 commit comments