[GRASS-SVN] r65943 - in grass/trunk/lib/python/pygrass/modules: . grid testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 15 14:41:15 PDT 2015
Author: zarch
Date: 2015-08-15 14:41:14 -0700 (Sat, 15 Aug 2015)
New Revision: 65943
Modified:
grass/trunk/lib/python/pygrass/modules/grid/grid.py
grass/trunk/lib/python/pygrass/modules/shortcuts.py
grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py
Log:
pygrass: fix modules doctests and make the tests indipendent from the mapset/location name
Modified: grass/trunk/lib/python/pygrass/modules/grid/grid.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/grid.py 2015-08-15 06:51:01 UTC (rev 65942)
+++ grass/trunk/lib/python/pygrass/modules/grid/grid.py 2015-08-15 21:41:14 UTC (rev 65943)
@@ -69,20 +69,22 @@
:returns: the instance of the new Mapset.
+ >>> from grass.script.core import gisenv
+ >>> mname = gisenv()['MAPSET']
>>> mset = Mapset()
- >>> mset.name
- 'user1'
+ >>> mset.name == mname
+ True
>>> import tempfile as tmp
>>> import os
>>> path = os.path.join(tmp.gettempdir(), 'my_loc', 'my_mset')
- >>> copy_mapset(mset, path)
- Mapset('user1')
- >>> sorted(os.listdir(path))
- [u'PERMANENT', u'user1']
+ >>> copy_mapset(mset, path) # doctest: +ELLIPSIS
+ Mapset(...)
+ >>> sorted(os.listdir(path)) # doctest: +ELLIPSIS
+ [...'PERMANENT'...]
>>> sorted(os.listdir(os.path.join(path, 'PERMANENT')))
[u'DEFAULT_WIND', u'PROJ_INFO', u'PROJ_UNITS', u'VAR', u'WIND']
- >>> sorted(os.listdir(os.path.join(path, 'user1'))) # doctest: +ELLIPSIS
- [...u'SEARCH_PATH', u'VAR', u'WIND']
+ >>> sorted(os.listdir(os.path.join(path, mname))) # doctest: +ELLIPSIS
+ [...u'SEARCH_PATH',...u'WIND']
>>> import shutil
>>> shutil.rmtree(path)
@@ -110,8 +112,12 @@
:returns: a tuple with the mapset, location and gisdbase
>>> import os
- >>> read_gisrc(os.environ['GISRC']) # doctest: +ELLIPSIS
- (u'user1', ...)
+ >>> from grass.script.core import gisenv
+ >>> genv = gisenv()
+ >>> (read_gisrc(os.environ['GISRC']) == (genv['MAPSET'],
+ ... genv['LOCATION_NAME'],
+ ... genv['GISDBASE']))
+ True
"""
with open(gisrc, 'r') as gfile:
gis = dict([(k.strip(), v.strip())
Modified: grass/trunk/lib/python/pygrass/modules/shortcuts.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/shortcuts.py 2015-08-15 06:51:01 UTC (rev 65942)
+++ grass/trunk/lib/python/pygrass/modules/shortcuts.py 2015-08-15 21:41:14 UTC (rev 65943)
@@ -21,11 +21,12 @@
>>> g_list.required
['type']
>>> g_list.inputs.type = 'raster'
+ >>> g_list.inputs.mapset = 'PERMANENT'
>>> g_list.stdout_ = -1
>>> g_list.run()
Module('g.list')
>>> g_list.outputs.stdout # doctest: +ELLIPSIS
- '...basins...soils...'
+ '...basin...soils...'
>>> r = MetaModule('r')
>>> what = r.what
>>> what.description
Modified: grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py 2015-08-15 06:51:01 UTC (rev 65942)
+++ grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py 2015-08-15 21:41:14 UTC (rev 65943)
@@ -9,7 +9,7 @@
import grass.gunittest.main
import grass.gunittest.utils
-import grass.pygrass.modules as gmodules
+from grass.pygrass.modules import shortcuts, grid, interface
# doctest does not allow changing the base classes of test case, skip test case
@@ -31,11 +31,11 @@
# for now it is the only place where it works
grass.gunittest.utils.do_doctest_gettext_workaround()
# this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gmodules.interface))
- tests.addTests(doctest.DocTestSuite(gmodules.grid.grid))
- tests.addTests(doctest.DocTestSuite(gmodules.grid.patch))
- tests.addTests(doctest.DocTestSuite(gmodules.grid.split))
- tests.addTests(doctest.DocTestSuite(gmodules.shortcuts))
+ tests.addTests(doctest.DocTestSuite(interface))
+ tests.addTests(doctest.DocTestSuite(grid.grid))
+ tests.addTests(doctest.DocTestSuite(grid.patch))
+ tests.addTests(doctest.DocTestSuite(grid.split))
+ tests.addTests(doctest.DocTestSuite(shortcuts))
return tests
More information about the grass-commit
mailing list