-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grass.pygrass: Support shortened parameter values (#3275)
Command line interface parser allows parameter (option) values such as 'val' when full value should be 'value'. Parameter class from pygrass does the checking, but does not know about these rules. This addition covers the simple case of val-value which is not much work to implement and maintain. It does not cover more complex cases with underscores and legacy aliases. The test covers the issue for use=value change in v.to.rast made in #3110. Strict checking in pygrass is discussed in #3237.
- Loading branch information
1 parent
ea8f3ea
commit 968dd70
Showing
2 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Name: v.to.rast test | ||
Purpose: Test v.to.rast | ||
Author: Vaclav Petras | ||
Copyright: (C) 2023 by Vaclav Petras and the GRASS Development Team | ||
Licence: This program is free software under the GNU General Public | ||
License (>=v2). Read the file COPYING that comes with GRASS | ||
for details. | ||
""" | ||
from grass.gunittest.case import TestCase | ||
from grass.gunittest.main import test | ||
|
||
|
||
class TestParameters(TestCase): | ||
"""Test v.to.rast""" | ||
|
||
output = "roads" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Specify region for raster creation for this class""" | ||
cls.use_temp_region() | ||
cls.runModule("g.region", raster="roadsmajor", res=10, flags="a") | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""Remove temporary region""" | ||
cls.del_temp_region() | ||
|
||
def tearDown(self): | ||
"""Remove maps after each test method""" | ||
self.runModule( | ||
"g.remove", | ||
flags="f", | ||
type="raster", | ||
name=[self.output], | ||
) | ||
|
||
def test_legacy_use_interface(self): | ||
"""Check that a legacy value for use parameter works""" | ||
self.assertModule( | ||
"v.to.rast", input="roadsmajor", output=self.output, use="val", value=1 | ||
) | ||
|
||
def test_use_interface(self): | ||
"""Check that use=value value=1 works""" | ||
self.assertModule( | ||
"v.to.rast", input="roadsmajor", output=self.output, use="value", value=1 | ||
) | ||
self.assertRasterFitsInfo(raster=self.output, reference={"min": 1, "max": 1}) | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |