[GRASS-SVN] r60677 - in sandbox/wenzeslaus/gunittest: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 2 20:49:05 PDT 2014
Author: wenzeslaus
Date: 2014-06-02 20:49:04 -0700 (Mon, 02 Jun 2014)
New Revision: 60677
Added:
sandbox/wenzeslaus/gunittest/testsuite/
sandbox/wenzeslaus/gunittest/testsuite/test_assertions.py
sandbox/wenzeslaus/gunittest/testsuite/test_doctests.py
Log:
gunittest: tests for ellipsis assertion and doctest
Added: sandbox/wenzeslaus/gunittest/testsuite/test_assertions.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/test_assertions.py (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/test_assertions.py 2014-06-03 03:49:04 UTC (rev 60677)
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+"""
+Tests assertion methods.
+"""
+
+
+import sys
+import os
+
+# import gunittest as a package so that relative imports there works
+sys.path.insert(0, os.path.split(os.path.split((os.path.dirname(__file__)))[0])[0])
+from gunittest.case import GrassTestCase
+
+
+class TestTextAssertions(GrassTestCase):
+ def test_assertLooksLike(self):
+ self.assertLooksLike("Generated map is <elevation>",
+ "Generated map is <...>")
+ self.assertRaises(self.failureException,
+ self.assertLooksLike, "Generated map is elevation.",
+ "Generated map is <...>")
Property changes on: sandbox/wenzeslaus/gunittest/testsuite/test_assertions.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
Added: sandbox/wenzeslaus/gunittest/testsuite/test_doctests.py
===================================================================
--- sandbox/wenzeslaus/gunittest/testsuite/test_doctests.py (rev 0)
+++ sandbox/wenzeslaus/gunittest/testsuite/test_doctests.py 2014-06-03 03:49:04 UTC (rev 60677)
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import os
+import sys
+import doctest
+
+# import gunittest as a package so that relative imports there works
+sys.path.insert(0, os.path.split(os.path.split((os.path.dirname(__file__)))[0])[0])
+import gunittest
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# 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.case.GrassTestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (gunittest.case.GrassTestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ tests.addTests(doctest.DocTestSuite(gunittest.checkers))
+ return tests
Property changes on: sandbox/wenzeslaus/gunittest/testsuite/test_doctests.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list