Skip to content

Commit

Permalink
r.semantic.label: fix print raster map semantic label (#3595)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi committed Apr 14, 2024
1 parent 1adb566 commit 2bf659a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/r.semantic.label/r.semantic.label.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def print_map_semantic_label(name, label_reader):
with RasterRow(name) as rast:
semantic_label = rast.info.semantic_label
if semantic_label:
label_reader.print_info(semantic_label)
label_reader.print_info(semantic_label=semantic_label)
else:
gs.info(_("No semantic label assigned to <{}>").format(name))
except OpenError as e:
Expand Down
17 changes: 16 additions & 1 deletion scripts/r.semantic.label/testsuite/test_r_semantic_label.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.gmodules import SimpleModule, call_module
from grass.gunittest.gmodules import SimpleModule

from grass.script.core import tempname
from grass.pygrass.gis import Mapset
Expand Down Expand Up @@ -46,6 +46,21 @@ def test_semantic_label_assign(self):
# check also using pygrass
self.assertEqual(self.read_semantic_label(), self.semantic_label)

def test_semantic_label_print(self):
semantic_label = "S2_1"
semantic_label_desc = "S2 Visible (Coastal/Aerosol)"
module = SimpleModule(
"r.semantic.label",
map=self.map,
semantic_label=semantic_label,
)
self.assertModule(module)

module = SimpleModule("r.semantic.label", map=self.map, operation="print")
self.assertModule(module)

self.assertEqual(module.outputs.stdout.strip(), semantic_label_desc)

def test_semantic_label_dissociate(self):
module = SimpleModule("r.semantic.label", operation="remove", map=self.map)
self.assertModule(module)
Expand Down

0 comments on commit 2bf659a

Please sign in to comment.