Robert Brewer avatar 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.

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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.