From cef11a06100cf01502107f341627c471a3686b93 Mon Sep 17 00:00:00 2001
From: Iacopo Spalletti <i.spalletti@nephila.it>
Date: Sun, 20 Apr 2014 20:19:47 +0200
Subject: [PATCH] Test for #22478
---
tests/test_suite_override/sample_app/__init__.py | 1 +
tests/test_suite_override/sample_app/models.py | 5 +++++
tests/test_suite_override/sample_app/tests/__init__.py | 2 ++
.../test_suite_override/sample_app/tests/test_module.py | 11 +++++++++++
tests/test_suite_override/tests.py | 16 +++++++++++++++-
5 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 tests/test_suite_override/sample_app/__init__.py
create mode 100644 tests/test_suite_override/sample_app/models.py
create mode 100644 tests/test_suite_override/sample_app/tests/__init__.py
create mode 100644 tests/test_suite_override/sample_app/tests/test_module.py
diff --git a/tests/test_suite_override/sample_app/__init__.py b/tests/test_suite_override/sample_app/__init__.py
new file mode 100644
index 0000000..7c68785
-
|
+
|
|
| 1 | # -*- coding: utf-8 -*- |
| 2 | No newline at end of file |
diff --git a/tests/test_suite_override/sample_app/models.py b/tests/test_suite_override/sample_app/models.py
new file mode 100644
index 0000000..1a5378a
-
|
+
|
|
| 1 | # -*- coding: utf-8 -*- |
| 2 | from django.db import models |
| 3 | |
| 4 | class MyModel(models.Model): |
| 5 | title = models.CharField(max_length=200) |
| 6 | No newline at end of file |
diff --git a/tests/test_suite_override/sample_app/tests/__init__.py b/tests/test_suite_override/sample_app/tests/__init__.py
new file mode 100644
index 0000000..da6fc65
-
|
+
|
|
| 1 | # -*- coding: utf-8 -*- |
| 2 | from .test_module import * |
| 3 | No newline at end of file |
diff --git a/tests/test_suite_override/sample_app/tests/test_module.py b/tests/test_suite_override/sample_app/tests/test_module.py
new file mode 100644
index 0000000..7e22265
-
|
+
|
|
| 1 | # -*- coding: utf-8 -*- |
| 2 | import unittest |
| 3 | from django.test.utils import IgnoreAllDeprecationWarningsMixin |
| 4 | |
| 5 | |
| 6 | class StubTest(IgnoreAllDeprecationWarningsMixin, unittest.TestCase): |
| 7 | |
| 8 | def test_void(self): |
| 9 | """ |
| 10 | This is actually a void test, just to check if it's loaded |
| 11 | """ |
| 12 | No newline at end of file |
diff --git a/tests/test_suite_override/tests.py b/tests/test_suite_override/tests.py
index c485b80..9025f32 100644
a
|
b
|
|
1 | 1 | import unittest |
2 | 2 | |
3 | 3 | from django.apps import apps |
4 | | from django.test.utils import IgnoreAllDeprecationWarningsMixin |
| 4 | from django.test.utils import (IgnoreAllDeprecationWarningsMixin, |
| 5 | override_settings) |
5 | 6 | |
6 | 7 | |
7 | 8 | def suite(): |
… |
… |
class SuiteOverrideTest(IgnoreAllDeprecationWarningsMixin, unittest.TestCase):
|
24 | 25 | suite = build_suite(app_config) |
25 | 26 | self.assertEqual(suite.countTestCases(), 1) |
26 | 27 | |
| 28 | @override_settings(INSTALLED_APPS=['test_suite_override.sample_app']) |
| 29 | def test_build_tests(self): |
| 30 | """ |
| 31 | This test is for #22478 |
| 32 | |
| 33 | when an application has test directory with tests organized in different |
| 34 | modules inside the test directory, every application module must be |
| 35 | checked for the passed test labels. |
| 36 | """ |
| 37 | from django.test.simple import build_test |
| 38 | suite = build_test("sample_app.StubTest") |
| 39 | self.assertEqual(suite.countTestCases(), 1) |
| 40 | |
27 | 41 | |
28 | 42 | class SampleTests(unittest.TestCase): |
29 | 43 | """These tests should not be discovered, due to the custom suite.""" |