Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12932 -- Added an extra argument to suite_result() in the test…

… runner, and added **kwargs as protection against future changes. Thanks to Eric Holscher for the report and patch.

This is BACKWARDS INCOMPATIBLE for anyone that has written a custom DjangoTestRunner class since it was introduced in r12255.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12487 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2fc19d8d6f369d4bd1ef8c7175c241a10e24c6f0 1 parent a9b2ac2
Russell Keith-Magee authored February 22, 2010
20  django/test/simple.py
@@ -232,16 +232,16 @@ def reorder_suite(suite, classes):
232 232
 
233 233
 
234 234
 class DjangoTestSuiteRunner(object):
235  
-    def __init__(self, verbosity=1, interactive=True, failfast=True):
  235
+    def __init__(self, verbosity=1, interactive=True, failfast=True, **kwargs):
236 236
         self.verbosity = verbosity
237 237
         self.interactive = interactive
238 238
         self.failfast = failfast
239 239
 
240  
-    def setup_test_environment(self):
  240
+    def setup_test_environment(self, **kwargs):
241 241
         setup_test_environment()
242 242
         settings.DEBUG = False
243 243
 
244  
-    def build_suite(self, test_labels, extra_tests=None):
  244
+    def build_suite(self, test_labels, extra_tests=None, **kwargs):
245 245
         suite = unittest.TestSuite()
246 246
 
247 247
         if test_labels:
@@ -261,7 +261,7 @@ def build_suite(self, test_labels, extra_tests=None):
261 261
 
262 262
         return reorder_suite(suite, (TestCase,))
263 263
 
264  
-    def setup_databases(self):
  264
+    def setup_databases(self, **kwargs):
265 265
         from django.db import connections
266 266
         old_names = []
267 267
         mirrors = []
@@ -278,10 +278,10 @@ def setup_databases(self):
278 278
                 connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
279 279
         return old_names, mirrors
280 280
 
281  
-    def run_suite(self, suite):
  281
+    def run_suite(self, suite, **kwargs):
282 282
         return DjangoTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite)
283 283
 
284  
-    def teardown_databases(self, old_config):
  284
+    def teardown_databases(self, old_config, **kwargs):
285 285
         from django.db import connections
286 286
         old_names, mirrors = old_config
287 287
         # Point all the mirrors back to the originals
@@ -291,13 +291,13 @@ def teardown_databases(self, old_config):
291 291
         for connection, old_name in old_names:
292 292
             connection.creation.destroy_test_db(old_name, self.verbosity)
293 293
 
294  
-    def teardown_test_environment(self):
  294
+    def teardown_test_environment(self, **kwargs):
295 295
         teardown_test_environment()
296 296
 
297  
-    def suite_result(self, result):
  297
+    def suite_result(self, suite, result, **kwargs):
298 298
         return len(result.failures) + len(result.errors)
299 299
 
300  
-    def run_tests(self, test_labels, extra_tests=None):
  300
+    def run_tests(self, test_labels, extra_tests=None, **kwargs):
301 301
         """
302 302
         Run the unit tests for all the test labels in the provided list.
303 303
         Labels must be of the form:
@@ -322,7 +322,7 @@ def run_tests(self, test_labels, extra_tests=None):
322 322
         result = self.run_suite(suite)
323 323
         self.teardown_databases(old_config)
324 324
         self.teardown_test_environment()
325  
-        return self.suite_result(result)
  325
+        return self.suite_result(suite, result)
326 326
 
327 327
 def run_tests(test_labels, verbosity=1, interactive=True, failfast=False, extra_tests=None):
328 328
     import warnings
19  docs/topics/testing.txt
@@ -1371,7 +1371,7 @@ set up, execute and tear down the test suite.
1371 1371
     write your own test runner, ensure accept and handle the ``**kwargs``
1372 1372
     parameter.
1373 1373
 
1374  
-.. method:: DjangoTestSuiteRunner.run_tests(test_labels, extra_tests=None)
  1374
+.. method:: DjangoTestSuiteRunner.run_tests(test_labels, extra_tests=None, **kwargs)
1375 1375
 
1376 1376
     Run the test suite.
1377 1377
 
@@ -1392,11 +1392,11 @@ set up, execute and tear down the test suite.
1392 1392
 
1393 1393
     This method should return the number of tests that failed.
1394 1394
 
1395  
-.. method:: DjangoTestSuiteRunner.setup_test_environment()
  1395
+.. method:: DjangoTestSuiteRunner.setup_test_environment(**kwargs)
1396 1396
 
1397 1397
     Sets up the test environment ready for testing.
1398 1398
 
1399  
-.. method:: DjangoTestSuiteRunner.build_suite(test_labels, extra_tests=None)
  1399
+.. method:: DjangoTestSuiteRunner.build_suite(test_labels, extra_tests=None, **kwargs)
1400 1400
 
1401 1401
     Constructs a test suite that matches the test labels provided.
1402 1402
 
@@ -1417,7 +1417,7 @@ set up, execute and tear down the test suite.
1417 1417
 
1418 1418
     Returns a ``TestSuite`` instance ready to be run.
1419 1419
 
1420  
-.. method:: DjangoTestSuiteRunner.setup_databases()
  1420
+.. method:: DjangoTestSuiteRunner.setup_databases(**kwargs)
1421 1421
 
1422 1422
     Creates the test databases.
1423 1423
 
@@ -1425,13 +1425,13 @@ set up, execute and tear down the test suite.
1425 1425
     that have been made. This data will be provided to the ``teardown_databases()``
1426 1426
     function at the conclusion of testing.
1427 1427
 
1428  
-.. method:: DjangoTestSuiteRunner.run_suite(suite)
  1428
+.. method:: DjangoTestSuiteRunner.run_suite(suite, **kwargs)
1429 1429
 
1430 1430
     Runs the test suite.
1431 1431
 
1432 1432
     Returns the result produced by the running the test suite.
1433 1433
 
1434  
-.. method:: DjangoTestSuiteRunner.teardown_databases(old_config)
  1434
+.. method:: DjangoTestSuiteRunner.teardown_databases(old_config, **kwargs)
1435 1435
 
1436 1436
     Destroys the test databases, restoring pre-test conditions.
1437 1437
 
@@ -1439,13 +1439,14 @@ set up, execute and tear down the test suite.
1439 1439
     database configuration that need to be reversed. It is the return
1440 1440
     value of the ``setup_databases()`` method.
1441 1441
 
1442  
-.. method:: DjangoTestSuiteRunner.teardown_test_environment()
  1442
+.. method:: DjangoTestSuiteRunner.teardown_test_environment(**kwargs)
1443 1443
 
1444 1444
     Restores the pre-test environment.
1445 1445
 
1446  
-.. method:: DjangoTestSuiteRunner.suite_result(result)
  1446
+.. method:: DjangoTestSuiteRunner.suite_result(suite, result, **kwargs)
1447 1447
 
1448  
-    Computes and returns a return code based on a test suite result.
  1448
+    Computes and returns a return code based on a test suite, and the result
  1449
+	from that test suite.
1449 1450
 
1450 1451
 
1451 1452
 Testing utilities

0 notes on commit 2fc19d8

Please sign in to comment.
Something went wrong with that request. Please try again.