Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Modified test_client_override to work with unittest2 discovery.

  • Loading branch information...
commit 6f3e1397394da838db9e9aee6ba0eb102ac6f49b 1 parent 751b007
Preston Timmons authored April 12, 2013 carljm committed April 12, 2013
21  tests/test_client_override/tests.py
... ...
@@ -1,21 +0,0 @@
1  
-from django.utils import unittest
2  
-
3  
-
4  
-def suite():
5  
-    """
6  
-    Validate that you can override the default test suite
7  
-    Define a suite that deliberately ignores a test defined in
8  
-    this module.
9  
-    """
10  
-
11  
-    testSuite = unittest.TestSuite()
12  
-    testSuite.addTest(SampleTests('testGoodStuff'))
13  
-    return testSuite
14  
-
15  
-
16  
-class SampleTests(unittest.TestCase):
17  
-    def testGoodStuff(self):
18  
-        pass
19  
-
20  
-    def testBadStuff(self):
21  
-        self.fail("This test shouldn't run")
0  tests/test_client_override/__init__.py → tests/test_suite_override/__init__.py
File renamed without changes
0  tests/test_client_override/models.py → tests/test_suite_override/models.py
File renamed without changes
34  tests/test_suite_override/tests.py
... ...
@@ -0,0 +1,34 @@
  1
+from django.db.models import get_app
  2
+from django.test.simple import build_suite
  3
+from django.utils import unittest
  4
+
  5
+
  6
+def suite():
  7
+    testSuite = unittest.TestSuite()
  8
+    testSuite.addTest(SuiteOverrideTest('test_suite_override'))
  9
+    return testSuite
  10
+
  11
+
  12
+class SuiteOverrideTest(unittest.TestCase):
  13
+    def test_suite_override(self):
  14
+        """
  15
+        Validate that you can define a custom suite when running tests with
  16
+        ``django.test.simple.DjangoTestSuiteRunner`` (which builds up a test
  17
+        suite using ``build_suite``).
  18
+        """
  19
+
  20
+        app = get_app("test_suite_override")
  21
+        suite = build_suite(app)
  22
+        self.assertEqual(suite.countTestCases(), 1)
  23
+
  24
+
  25
+class SampleTests(unittest.TestCase):
  26
+    """These tests should not be discovered, due to the custom suite."""
  27
+    def test_one(self):
  28
+        pass
  29
+
  30
+    def test_two(self):
  31
+        pass
  32
+
  33
+    def test_three(self):
  34
+        pass

0 notes on commit 6f3e139

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