From 6f3e1397394da838db9e9aee6ba0eb102ac6f49b Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Fri, 12 Apr 2013 15:04:40 -0600 Subject: [PATCH] Modified test_client_override to work with unittest2 discovery. --- tests/test_client_override/tests.py | 21 ------------ .../__init__.py | 0 .../models.py | 0 tests/test_suite_override/tests.py | 34 +++++++++++++++++++ 4 files changed, 34 insertions(+), 21 deletions(-) delete mode 100644 tests/test_client_override/tests.py rename tests/{test_client_override => test_suite_override}/__init__.py (100%) rename tests/{test_client_override => test_suite_override}/models.py (100%) create mode 100644 tests/test_suite_override/tests.py diff --git a/tests/test_client_override/tests.py b/tests/test_client_override/tests.py deleted file mode 100644 index ec97b776d9..0000000000 --- a/tests/test_client_override/tests.py +++ /dev/null @@ -1,21 +0,0 @@ -from django.utils import unittest - - -def suite(): - """ - Validate that you can override the default test suite - Define a suite that deliberately ignores a test defined in - this module. - """ - - testSuite = unittest.TestSuite() - testSuite.addTest(SampleTests('testGoodStuff')) - return testSuite - - -class SampleTests(unittest.TestCase): - def testGoodStuff(self): - pass - - def testBadStuff(self): - self.fail("This test shouldn't run") diff --git a/tests/test_client_override/__init__.py b/tests/test_suite_override/__init__.py similarity index 100% rename from tests/test_client_override/__init__.py rename to tests/test_suite_override/__init__.py diff --git a/tests/test_client_override/models.py b/tests/test_suite_override/models.py similarity index 100% rename from tests/test_client_override/models.py rename to tests/test_suite_override/models.py diff --git a/tests/test_suite_override/tests.py b/tests/test_suite_override/tests.py new file mode 100644 index 0000000000..dea110434f --- /dev/null +++ b/tests/test_suite_override/tests.py @@ -0,0 +1,34 @@ +from django.db.models import get_app +from django.test.simple import build_suite +from django.utils import unittest + + +def suite(): + testSuite = unittest.TestSuite() + testSuite.addTest(SuiteOverrideTest('test_suite_override')) + return testSuite + + +class SuiteOverrideTest(unittest.TestCase): + def test_suite_override(self): + """ + Validate that you can define a custom suite when running tests with + ``django.test.simple.DjangoTestSuiteRunner`` (which builds up a test + suite using ``build_suite``). + """ + + app = get_app("test_suite_override") + suite = build_suite(app) + self.assertEqual(suite.countTestCases(), 1) + + +class SampleTests(unittest.TestCase): + """These tests should not be discovered, due to the custom suite.""" + def test_one(self): + pass + + def test_two(self): + pass + + def test_three(self): + pass