diff --git a/lib/init/testsuite/test_grass_tmp_mapset.py b/lib/init/testsuite/test_grass_tmp_mapset.py index 92cf3b7e426..000f202c73b 100644 --- a/lib/init/testsuite/test_grass_tmp_mapset.py +++ b/lib/init/testsuite/test_grass_tmp_mapset.py @@ -26,10 +26,21 @@ class TestTmpMapset(unittest.TestCase): """Tests --tmp-mapset option of grass command""" - # TODO: here we need a name of or path to the main GRASS executable - # TODO: support OSGeo4W executable with: - # executable = "grass" if os.name != "nt" else "grass86.bat" - executable = "grass" if os.name != "nt" else "grass.bat" + # On Windows, GISBASE itself (where the grass.bat launcher lives) is + # never added to PATH, only GISBASE\bin is, so a bare "grass.bat" is + # not found when this test runs inside an existing GRASS session (e.g. + # under grass.gunittest.main). Resolve the full path via GISBASE when + # available and fall back to the bare name otherwise. + # Note: on an OSGeo4W package install, the launcher name is versioned + # (e.g. grass86.bat instead of grass.bat), so this resolution does not + # apply there; it only covers a from-source build's layout. + _gisbase = os.environ.get("GISBASE") + if os.name != "nt": + executable = "grass" + elif _gisbase: + executable = os.path.join(_gisbase, "grass.bat") + else: + executable = "grass.bat" # an arbitrary, but identifiable and fairly unique name location = "test_tmp_mapset_xy" diff --git a/scripts/db.univar/db.univar.py b/scripts/db.univar/db.univar.py index fc8fb670e93..b0eaf600163 100755 --- a/scripts/db.univar/db.univar.py +++ b/scripts/db.univar/db.univar.py @@ -77,9 +77,7 @@ def sortfile(infile, outfile): else: # FIXME: we need a large-file sorting function gs.warning(_("'sort' not found: sorting in memory")) - lines = inf.readlines() - for i in range(len(lines)): - lines[i] = float(lines[i].rstrip("\r\n")) + lines = [float(line) for line in (line.strip() for line in inf) if line] lines.sort() outf.writelines(str(line) + "\n" for line in lines)