Commits

Robert Brewer committed 2e7786f

webtest sys.e[X]it option now works. There's also a new WebCase.exit() method which you can override, in case you need to do other things before exiting.

  • Participants
  • Parent commits 7b3c8be

Comments (0)

Files changed (1)

cherrypy/test/webtest.py

             elif i == "R":
                 raise self.failureException(msg)
             elif i == "X":
-                sys.exit()
+                self.exit()
             print p,
     
+    def exit(self):
+        sys.exit()
+    
+    def __call__(self, result=None):
+        if result is None:
+            result = self.defaultTestResult()
+        result.startTest(self)
+        testMethod = getattr(self, self._TestCase__testMethodName)
+        try:
+            try:
+                self.setUp()
+            except (KeyboardInterrupt, SystemExit):
+                raise
+            except:
+                result.addError(self, self._TestCase__exc_info())
+                return
+            
+            ok = 0
+            try:
+                testMethod()
+                ok = 1
+            except self.failureException:
+                result.addFailure(self, self._TestCase__exc_info())
+            except (KeyboardInterrupt, SystemExit):
+                raise
+            except:
+                result.addError(self, self._TestCase__exc_info())
+            
+            try:
+                self.tearDown()
+            except (KeyboardInterrupt, SystemExit):
+                raise
+            except:
+                result.addError(self, self._TestCase__exc_info())
+                ok = 0
+            if ok:
+                result.addSuccess(self)
+        finally:
+            result.stopTest(self)
+    
     def assertStatus(self, status, msg=None):
         """Fail if self.status != status."""
         if not self.status == status: