[shell, testlib] return doc test results in process_script and new assertDocTestFile method on CubicWebTC stable
authorJulien Jehannet <julien.jehannet@logilab.fr>
Fri, 05 Nov 2010 15:08:24 +0100
branchstable
changeset 6687 0b1f5c14646e
parent 6686 070e3b23160d
child 6688 51ddb4842c56
[shell, testlib] return doc test results in process_script and new assertDocTestFile method on CubicWebTC
devtools/testlib.py
migration.py
--- a/devtools/testlib.py	Fri Nov 05 16:38:17 2010 +0100
+++ b/devtools/testlib.py	Fri Nov 05 15:08:24 2010 +0100
@@ -661,6 +661,13 @@
 
     # content validation #######################################################
 
+    def assertDocTestFile(self, testfile):
+        # doctest returns tuple (failure_count, test_count)
+        result = self.shell.process_script(testfile)
+        if result[0] and result[1]:
+            raise self.failureException("doctest file '%s' failed"
+                                        % testfile)
+
     # validators are used to validate (XML, DTD, whatever) view's content
     # validators availables are :
     #  DTDValidator : validates XML + declared DTD
--- a/migration.py	Fri Nov 05 16:38:17 2010 +0100
+++ b/migration.py	Fri Nov 05 15:08:24 2010 +0100
@@ -358,8 +358,10 @@
             self.commit()
         else: # script_mode == 'doctest'
             import doctest
-            doctest.testfile(migrscript, module_relative=False,
-                             optionflags=doctest.ELLIPSIS, globs=scriptlocals)
+            return doctest.testfile(migrscript, module_relative=False,
+                                    optionflags=doctest.ELLIPSIS,
+                                    encoding='utf-8',
+                                    globs=scriptlocals)
         self._context_stack.pop()
 
     def cmd_option_renamed(self, oldname, newname):