[GRASS-SVN] r61226 - in grass/trunk: general/g.list/testsuite general/g.mlist/testsuite general/g.mremove/testsuite lib/python lib/python/gunittest lib/python/gunittest/testsuite lib/python/temporal/testsuite raster/r.gwflow/testsuite raster/r.slope.aspect/testsuite temporal/t.rast.extract/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 9 19:00:34 PDT 2014


Author: wenzeslaus
Date: 2014-07-09 19:00:33 -0700 (Wed, 09 Jul 2014)
New Revision: 61226

Added:
   grass/trunk/lib/python/gunittest/Makefile
Modified:
   grass/trunk/general/g.list/testsuite/test_g_list.py
   grass/trunk/general/g.mlist/testsuite/test_g_mlist.py
   grass/trunk/general/g.mremove/testsuite/test_g_mremove.py
   grass/trunk/lib/python/Makefile
   grass/trunk/lib/python/gunittest/testsuite/test_assertions.py
   grass/trunk/lib/python/gunittest/testsuite/test_checkers.py
   grass/trunk/lib/python/gunittest/testsuite/test_doctests.py
   grass/trunk/lib/python/gunittest/testsuite/test_gmodules.py
   grass/trunk/lib/python/gunittest/testsuite/test_module_assertions.py
   grass/trunk/lib/python/temporal/testsuite/unittests_register.py
   grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py
   grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py
   grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py
   grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
Log:
gunittest: makefiles and import as a standard grass package (so far no reason for different import)

Modified: grass/trunk/general/g.list/testsuite/test_g_list.py
===================================================================
--- grass/trunk/general/g.list/testsuite/test_g_list.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/general/g.list/testsuite/test_g_list.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -1,5 +1,5 @@
 
-import gunittest
+import grass.gunittest
 from grass.script import read_command
 
 LIST_RASTERS = """----------------------------------------------
@@ -126,7 +126,7 @@
 """
 
 
-class GListTest(gunittest.TestCase):
+class GListTest(grass.gunittest.TestCase):
 
     def test_list_rasters(self):
         """Test human readable list of rasters.
@@ -180,4 +180,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/general/g.mlist/testsuite/test_g_mlist.py
===================================================================
--- grass/trunk/general/g.mlist/testsuite/test_g_mlist.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/general/g.mlist/testsuite/test_g_mlist.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -1,10 +1,10 @@
 """g.mlist tests"""
 
-import gunittest
-from gunittest.gmodules import SimpleModule
+import grass.gunittest
+from grass.gunittest.gmodules import SimpleModule
 
 
-class GMlistWrongParamertersTest(gunittest.TestCase):
+class GMlistWrongParamertersTest(grass.gunittest.TestCase):
     """Test wrong input of parameters for g.mlist module"""
 
     @classmethod
@@ -52,4 +52,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/general/g.mremove/testsuite/test_g_mremove.py
===================================================================
--- grass/trunk/general/g.mremove/testsuite/test_g_mremove.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/general/g.mremove/testsuite/test_g_mremove.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -3,9 +3,9 @@
 # TODO: rmapcalc probably fatals, replace or add raise on error?
 from grass.script.raster import mapcalc as rmapcalc
 
-import gunittest
-from gunittest.gutils import get_curret_mapset
-from gunittest.gmodules import SimpleModule
+import grass.gunittest
+from grass.gunittest.gutils import get_current_mapset
+from grass.gunittest.gmodules import SimpleModule
 
 # when used user1 must be replaced by current mapset
 REMOVE_RASTERS = """rast/test_map_0 at user1
@@ -35,7 +35,7 @@
 """
 
 
-class GMRemoveTest(gunittest.TestCase):
+class GMRemoveTest(grass.gunittest.TestCase):
     """Test removing with g.mremove"""
 
     @classmethod
@@ -60,7 +60,7 @@
         self.assertModule(module)
         self.assertMultiLineEqual(module.outputs.stdout,
                                   REMOVE_RASTERS.replace('user1',
-                                                         get_curret_mapset()))
+                                                         get_current_mapset()))
 
         module = SimpleModule('g.mremove', type='rast',
                               pattern='test_map_*,*two', flags='f')
@@ -82,7 +82,7 @@
                                   'rast/test_apples at user1\n'
                                   'rast/test_apples_big at user1\n'
                                   'rast/test_oranges at user1\n'.replace(
-                                      'user1', get_curret_mapset()))
+                                      'user1', get_current_mapset()))
         module = SimpleModule('g.mremove', type='rast',
                               pattern='test_{apples,oranges}{_small,_big,*}',
                               flags='f')
@@ -92,7 +92,7 @@
                                  msg="4 maps should be removed")
 
 
-class GMRemoveWrongInputTest(gunittest.TestCase):
+class GMRemoveWrongInputTest(grass.gunittest.TestCase):
     """Test wrong input of parameters for g.mlist module"""
 
     def test_re_flags(self):
@@ -106,4 +106,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/Makefile
===================================================================
--- grass/trunk/lib/python/Makefile	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/Makefile	2014-07-10 02:00:33 UTC (rev 61226)
@@ -5,7 +5,7 @@
 
 PYDIR = $(ETC)/python/grass
 
-SUBDIRS = exceptions script ctypes temporal pygrass pydispatch imaging
+SUBDIRS = exceptions script ctypes temporal pygrass pydispatch imaging gunittest
 
 default: $(PYDIR)/__init__.py
 	$(MAKE) subdirs

Added: grass/trunk/lib/python/gunittest/Makefile
===================================================================
--- grass/trunk/lib/python/gunittest/Makefile	                        (rev 0)
+++ grass/trunk/lib/python/gunittest/Makefile	2014-07-10 02:00:33 UTC (rev 61226)
@@ -0,0 +1,27 @@
+MODULE_TOPDIR = ../../..
+
+include $(MODULE_TOPDIR)/include/Make/Other.make
+include $(MODULE_TOPDIR)/include/Make/Python.make
+
+PYDIR = $(ETC)/python
+GDIR = $(PYDIR)/grass
+DSTDIR = $(GDIR)/gunittest
+
+MODULES = case gmodules loader runner checkers gutils invoker main reporters utils
+
+PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__)
+PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__)
+
+default: $(PYFILES) $(PYCFILES) $(GDIR)/__init__.py $(GDIR)/__init__.pyc
+
+$(PYDIR):
+	$(MKDIR) $@
+
+$(GDIR): | $(PYDIR)
+	$(MKDIR) $@
+
+$(DSTDIR): | $(GDIR)
+	$(MKDIR) $@
+
+$(DSTDIR)/%: % | $(DSTDIR)
+	$(INSTALL_DATA) $< $@


Property changes on: grass/trunk/lib/python/gunittest/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Modified: grass/trunk/lib/python/gunittest/testsuite/test_assertions.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_assertions.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_assertions.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -10,11 +10,11 @@
 import grass.script.core as gcore
 from grass.pygrass.modules import Module
 
-import gunittest
-from gunittest.gmodules import SimpleModule
+import grass.gunittest
+from grass.gunittest.gmodules import SimpleModule
 
 
-class TestTextAssertions(gunittest.TestCase):
+class TestTextAssertions(grass.gunittest.TestCase):
     # pylint: disable=R0904
     def test_assertLooksLike(self):
         self.assertLooksLike("Generated map is <elevation>",
@@ -84,7 +84,7 @@
 """
 
 
-class TestAssertCommandKeyValue(gunittest.TestCase):
+class TestAssertCommandKeyValue(grass.gunittest.TestCase):
     """Test usage of `.assertCommandKeyValue` method."""
     # pylint: disable=R0904
 
@@ -125,7 +125,7 @@
                                    precision=0.01, sep='=')
 
 
-class TestRasterMapAssertations(gunittest.TestCase):
+class TestRasterMapAssertations(grass.gunittest.TestCase):
     # pylint: disable=R0904
 
     @classmethod
@@ -196,7 +196,7 @@
                           msg="The difference of different maps should have huge mean")
 
 
-class TestVectorMapAssertations(gunittest.TestCase):
+class TestVectorMapAssertations(grass.gunittest.TestCase):
     # pylint: disable=R0904
     def test_assertVectorFitsUnivar(self):
         self.assertVectorFitsUnivar(map='bridges', column='WIDTH',
@@ -213,7 +213,7 @@
                           reference=RANDOM_KEYVALUES)
 
 
-class TestFileAssertations(gunittest.TestCase):
+class TestFileAssertations(grass.gunittest.TestCase):
     # pylint: disable=R0904
 
     @classmethod
@@ -277,4 +277,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/gunittest/testsuite/test_checkers.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_checkers.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_checkers.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -16,13 +16,12 @@
 
 from grass.script.core import parse_key_val
 
-import gunittest
-from gunittest.checkers import (values_equal, text_to_keyvalue,
-                                keyvalue_equals,
-                                proj_info_equals, proj_units_equals)
+import grass.gunittest
+from grass.gunittest.checkers import (values_equal, text_to_keyvalue,
+    keyvalue_equals, proj_info_equals, proj_units_equals)
 
 
-class TestValuesEqual(gunittest.TestCase):
+class TestValuesEqual(grass.gunittest.TestCase):
 
     def test_floats(self):
         self.assertTrue(values_equal(5.0, 5.0))
@@ -115,7 +114,7 @@
 # what about keys and lower/upper case letters
 
 
-class TestTextToKeyValue(gunittest.TestCase):
+class TestTextToKeyValue(grass.gunittest.TestCase):
     def test_conversion(self):
         keyvals = text_to_keyvalue(KEYVAL_TEXT, sep=':', val_sep=',')
         expected = {'s': 'Hello',
@@ -217,14 +216,14 @@
                             'null_cells': 57995100, 'cells': 60020100}
 
 
-class TestComapreProjections(gunittest.TestCase):
+class TestComapreProjections(grass.gunittest.TestCase):
 
     def test_compare_proj_info(self):
         self.assertTrue(proj_info_equals(PROJ_INFO_TEXT_1, PROJ_INFO_TEXT_2))
         self.assertTrue(proj_units_equals(PROJ_UNITS_TEXT_1, PROJ_UNITS_TEXT_2))
 
 
-class TestParseKeyvalue(gunittest.TestCase):
+class TestParseKeyvalue(grass.gunittest.TestCase):
 
     def test_shell_script_style(self):
 
@@ -276,7 +275,7 @@
 """
 
 
-class TestRasterMapComparisons(gunittest.TestCase):
+class TestRasterMapComparisons(grass.gunittest.TestCase):
 
     def test_compare_univars(self):
         self.assertTrue(keyvalue_equals(text_to_keyvalue(R_UNIVAR_ELEVATION,
@@ -311,4 +310,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/gunittest/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_doctests.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_doctests.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -5,8 +5,8 @@
 
 import doctest
 
-import gunittest
-import gunittest.utils
+import grass.gunittest
+import grass.gunittest.utils
 
 
 # doctest does not allow changing the base classes of test case, skip test case
@@ -15,10 +15,10 @@
 # the alternative is to copy 500 from doctest and change what is needed
 # (this might be necessary anyway beacuse of the reports and stdout and stderr)
 doctest.DocFileCase = type('DocFileCase',
-                           (gunittest.TestCase,),
+                           (grass.gunittest.TestCase,),
                            dict(doctest.DocFileCase.__dict__))
 doctest.SkipDocTestCase = type('SkipDocTestCase',
-                               (gunittest.TestCase,),
+                               (grass.gunittest.TestCase,),
                                dict(doctest.SkipDocTestCase.__dict__))
 
 
@@ -26,12 +26,12 @@
     # TODO: this must be somewhere when doctest is called, not here
     # TODO: ultimate solution is not to use _ as a buildin in lib/python
     # for now it is the only place where it works
-    gunittest.utils.do_doctest_gettext_workaround()
+    grass.gunittest.utils.do_doctest_gettext_workaround()
     # this should be called at some top level
-    tests.addTests(doctest.DocTestSuite(gunittest.gmodules))
-    tests.addTests(doctest.DocTestSuite(gunittest.checkers))
+    tests.addTests(doctest.DocTestSuite(grass.gunittest.gmodules))
+    tests.addTests(doctest.DocTestSuite(grass.gunittest.checkers))
     return tests
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/gunittest/testsuite/test_gmodules.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_gmodules.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_gmodules.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -2,8 +2,8 @@
 
 import subprocess
 
-import gunittest
-from gunittest.gmodules import (call_module, CalledModuleError)
+import grass.gunittest
+from grass.gunittest.gmodules import (call_module, CalledModuleError)
 
 G_REGION_OUTPUT = """n=...
 s=...
@@ -17,7 +17,7 @@
 """
 
 
-class TestCallModuleFunction(gunittest.TestCase):
+class TestCallModuleFunction(grass.gunittest.TestCase):
 
     def test_output(self):
         output = call_module('g.region', flags='pg')
@@ -89,4 +89,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/gunittest/testsuite/test_module_assertions.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_module_assertions.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_module_assertions.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -5,11 +5,11 @@
 
 from grass.pygrass.modules import Module
 
-import gunittest
-from gunittest.gmodules import CalledModuleError
+import grass.gunittest
+from grass.gunittest.gmodules import CalledModuleError
 
 
-class TestModuleAssertions(gunittest.TestCase):
+class TestModuleAssertions(grass.gunittest.TestCase):
     # pylint: disable=R0904
 
     def setUp(self):
@@ -38,4 +38,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/lib/python/temporal/testsuite/unittests_register.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_register.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/lib/python/temporal/testsuite/unittests_register.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -11,11 +11,11 @@
 
 import grass.script as grass
 import grass.temporal as tgis
-import gunittest
+import grass.gunittest
 import datetime
 
 
-class TestRegisterFunctions(gunittest.TestCase):
+class TestRegisterFunctions(grass.gunittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
@@ -300,4 +300,4 @@
         self.assertEqual(unit, "seconds")
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py
===================================================================
--- grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -8,7 +8,7 @@
 @author Soeren Gebbert
 """
 import grass.script as grass
-from gunittest.case import TestCase
+from grass.gunittest.case import TestCase
 
 class Validation7x7Grid(TestCase):
 
@@ -84,7 +84,7 @@
 
 
 if __name__ == '__main__':
-    from gunittest.main import test
+    from grass.gunittest.main import test
     test()
 
 

Modified: grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py
===================================================================
--- grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -9,7 +9,7 @@
 """
 
 import grass.script as grass
-from gunittest.case import TestCase
+from grass.gunittest.case import TestCase
 
 class ValidationExcavation(TestCase):
 
@@ -82,7 +82,7 @@
         self.assertRasterFitsInfo(raster="gwresult",  reference=info_string,  precision=3)
 
 if __name__ == '__main__':
-    from gunittest.main import test
+    from grass.gunittest.main import test
     test()
 
 

Modified: grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -1,5 +1,5 @@
-import gunittest
-from gunittest.gmodules import call_module
+import grass.gunittest
+from grass.gunittest.gmodules import call_module
 
 SMALL_MAP = """\
 north:   15
@@ -16,7 +16,7 @@
 100.0 150.0 150.0 100.0 100.0
 """
 
-class TestSlopeAspect(gunittest.TestCase):
+class TestSlopeAspect(grass.gunittest.TestCase):
 
     def test_limits(self):
         slope = 'limits_slope'
@@ -39,7 +39,7 @@
                                 msg="Aspect in degrees must be between 0 and 360")
 
 
-class TestSlopeAspectAgainstReference(gunittest.TestCase):
+class TestSlopeAspectAgainstReference(grass.gunittest.TestCase):
     """
 
     Data created using::
@@ -102,7 +102,7 @@
                                        precision=self.precision)
 
 
-class TestSlopeAspectAgainstItself(gunittest.TestCase):
+class TestSlopeAspectAgainstItself(grass.gunittest.TestCase):
 
     precision = 0.0000001
 
@@ -136,7 +136,7 @@
 
 
 # TODO: implement this class
-class TestExtremes(gunittest.TestCase):
+class TestExtremes(grass.gunittest.TestCase):
 
     def setUp(self):
         self.use_temp_region()
@@ -160,4 +160,4 @@
 
 
 if __name__ == '__main__':
-    gunittest.test()
+    grass.gunittest.test()

Modified: grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py	2014-07-10 00:59:52 UTC (rev 61225)
+++ grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py	2014-07-10 02:00:33 UTC (rev 61226)
@@ -11,7 +11,7 @@
 import grass.script as grass
 import grass.pygrass.modules as pymod
 import subprocess
-from gunittest.case import TestCase
+from grass.gunittest.case import TestCase
 
 class TestRasterExtraction(TestCase):
 
@@ -151,5 +151,5 @@
                                                         reference=tinfo_string,  precision=2,  sep="=")
 
 if __name__ == '__main__':
-    from gunittest.main import test
+    from grass.gunittest.main import test
     test()



More information about the grass-commit mailing list