summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Picon <tabo@tabo.pe>2015-01-24 14:42:33 -0500
committerGustavo Picon <tabo@tabo.pe>2015-01-24 14:42:33 -0500
commit22937699ebf879b01d86d95a3c5e0fa8eefbcf74 (patch)
tree3f4e2721239176756012ff06c3ca6c73b661cb14
parent4d548ab536cd97d8328f7df1eacab286623098fa (diff)
downloadcherrypy-22937699ebf879b01d86d95a3c5e0fa8eefbcf74.tar.gz
Monkeypatch the test sorter to always run test_gc last in each suite.
The previous method introduced in 12f77856280c doesn't work with the unittest subclassed test suites cherrypy uses.
-rw-r--r--cherrypy/test/helper.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/cherrypy/test/helper.py b/cherrypy/test/helper.py
index b6ed3277..6c5471ab 100644
--- a/cherrypy/test/helper.py
+++ b/cherrypy/test/helper.py
@@ -6,6 +6,7 @@ log = logging.getLogger(__name__)
import os
thisdir = os.path.abspath(os.path.dirname(__file__))
serverpem = os.path.join(os.getcwd(), thisdir, 'test.pem')
+import unittest
import re
import sys
@@ -322,10 +323,6 @@ class CPWebCase(webtest.WebCase):
if self.do_gc_test:
self.getPage("/gc/stats")
self.assertBody("Statistics:")
- # Tell nose to run this last in each class.
- # Prefer sys.maxint for Python 2.3, which didn't have float('inf')
- test_gc.compat_co_firstlineno = getattr(
- sys, 'maxint', None) or float('inf')
def prefix(self):
return self.script_name.rstrip("/")
@@ -405,6 +402,20 @@ class CPWebCase(webtest.WebCase):
(dt1, dt2, seconds))
+def _test_method_sorter(_, x, y):
+ """Monkeypatch the test sorter to always run test_gc last in each suite."""
+ if x == 'test_gc':
+ return 1
+ if y == y == 'test_gc':
+ return -1
+ if x > y:
+ return 1
+ if x < y:
+ return -1
+ return 0
+unittest.TestLoader.sortTestMethodsUsing = _test_method_sorter
+
+
def setup_client():
"""Set up the WebCase classes to match the server's socket settings."""
webtest.WebCase.PORT = cherrypy.server.socket_port