[GRASS-SVN] r61134 - in sandbox/wenzeslaus/gunittest/testsuite: . data data/samplecode data/samplecode/submodule_errors data/samplecode/submodule_errors/subsubmodule_errors data/samplecode/submodule_errors/subsubmodule_errors/testsuite data/samplecode/submodule_errors/subsubmodule_exiting data/samplecode/submodule_errors/subsubmodule_exiting/testsuite data/samplecode/submodule_test_fail data/samplecode/submodule_test_fail/testsuite data/samplecode/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 2 21:03:02 PDT 2014


Author: wenzeslaus
Date: 2014-07-02 21:03:02 -0700 (Wed, 02 Jul 2014)
New Revision: 61134

Added:
   sandbox/wenzeslaus/gunittest/testsuite/data/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/fake_code.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/fake_code.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/fake_code.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_error.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_import_error.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/fake_code.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_gfatalerror.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_one.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_zero.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_segfaut.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_one.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_zero.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/fake_code.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/test_fail.py
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/
   sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/test_success.py
Log:
gunittest: sample code to test behavior at different occasions and to have fast testing runs

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/fake_code.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/fake_code.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/fake_code.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1 @@
+print "This is file (%s) should not run." % __file__


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/fake_code.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/fake_code.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/fake_code.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/fake_code.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1 @@
+print "This is file (%s) should not run." % __file__


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/fake_code.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/fake_code.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/fake_code.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/fake_code.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1 @@
+print "This is file (%s) should not run." % __file__


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/fake_code.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_error.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_error.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_error.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestError(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        raise RuntimeError('Error in test function')
+        self.assertTrue(True)
+
+
+class TestErrorSetUp(TestCase):
+    # pylint: disable=R0904
+
+    def setUp(self):
+        raise RuntimeError('Error in setUp')
+
+    def test_something(self):
+        self.assertTrue(True)
+
+
+class TestErrorTearDown(TestCase):
+    # pylint: disable=R0904
+
+    def tearDown(self):
+        raise RuntimeError('Error in tearDown')
+
+    def test_something(self):
+        self.assertTrue(True)
+
+
+class TestErrorClassSetUp(TestCase):
+    # pylint: disable=R0904
+
+    @classmethod
+    def setUpClass(cls):
+        raise RuntimeError('Error in setUpClass')
+
+    def test_something(self):
+        self.assertTrue(True)
+
+
+class TestErrorClassTearDown(TestCase):
+    # pylint: disable=R0904
+
+    @classmethod
+    def tearDownClass(cls):
+        raise RuntimeError('Error in tearDownClass')
+
+    def test_something(self):
+        self.assertTrue(True)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_error.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_import_error.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_import_error.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_import_error.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# comment to get rid of the wrong import
+# (if it is imported before all tests start)
+#import this_module_or_package_does_not_exists__testing_import_error
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestNeverCalled(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        self.assertFalse("This should not be called"
+                         " if we are testing failed import."
+                         " But it is good OK if one wrong import"
+                         " would prevent other tests from running"
+                         " due to the implementation of test invocation.")
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_errors/testsuite/test_import_error.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/fake_code.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/fake_code.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/fake_code.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1 @@
+print "This is file (%s) should not run." % __file__


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/fake_code.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_gfatalerror.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_gfatalerror.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_gfatalerror.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import grass.lib.gis as libgis
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestGFatalError(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        libgis.G_fatal_error("Testing G_fatal_error() function call")
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_gfatalerror.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_one.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_one.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_one.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import os
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestOsExit(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        os._exit(1)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_one.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_zero.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_zero.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_zero.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import os
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestOsExit(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        os._exit(0)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_osexit_zero.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_segfaut.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_segfaut.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_segfaut.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+import ctypes
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestSegfault(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        """Crash the Python interpreter"""
+        i = ctypes.c_char('a')
+        j = ctypes.pointer(i)
+        c = 0
+        while True:
+                j[c] = 'a'
+                c += 1
+        j
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_segfaut.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_one.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_one.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_one.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import sys
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestSysExit(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        sys.exit(1)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_one.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_zero.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_zero.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_zero.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import sys
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestSysExit(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        sys.exit(0)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_errors/subsubmodule_exiting/testsuite/test_sysexit_zero.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/fake_code.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/fake_code.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/fake_code.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1 @@
+print "This is file (%s) should not run." % __file__


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/fake_code.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/test_fail.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/test_fail.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/test_fail.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestFail(TestCase):
+    # pylint: disable=R0904
+
+    def test_something(self):
+        self.assertTrue(False)
+
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/submodule_test_fail/testsuite/test_fail.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/test_success.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/test_success.py	                        (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/test_success.py	2014-07-03 04:03:02 UTC (rev 61134)
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# TODO: change to GrassTestCase
+from unittest import TestCase
+
+
+class TestSuccessVerboseSetUp(TestCase):
+    # pylint: disable=R0904
+
+    def setUp(self):
+        print "print from setUp"
+
+    def tearDown(self):
+        print "print from tearDown"
+
+    def test_something(self):
+        self.assertTrue(True)
+
+
+class TestSuccessVerboseClassSetUp(TestCase):
+    # pylint: disable=R0904
+
+    @classmethod
+    def setUpClass(cls):
+        print "print from setUpClass"
+
+    @classmethod
+    def tearDownClass(cls):
+        print "print from tearDownClass"
+
+    def test_something(self):
+        self.assertTrue(True)
+
+if __name__ == '__main__':
+    import unittest
+    unittest.main()


Property changes on: sandbox/wenzeslaus/gunittest/testsuite/data/samplecode/testsuite/test_success.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list