Ticket #22478: 0002-Test-for-22478.patch

File 0002-Test-for-22478.patch, 3.7 KB (added by Iacopo Spalletti, 10 years ago)

Test

  • new file tests/test_suite_override/sample_app/__init__.py

    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
  • new file tests/test_suite_override/sample_app/models.py

    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 -*-
     2from django.db import models
     3
     4class MyModel(models.Model):
     5    title = models.CharField(max_length=200)
     6 No newline at end of file
  • new file tests/test_suite_override/sample_app/tests/__init__.py

    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 -*-
     2from .test_module import *
     3 No newline at end of file
  • new file tests/test_suite_override/sample_app/tests/test_module.py

    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 -*-
     2import unittest
     3from django.test.utils import IgnoreAllDeprecationWarningsMixin
     4
     5
     6class 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
  • tests/test_suite_override/tests.py

    diff --git a/tests/test_suite_override/tests.py b/tests/test_suite_override/tests.py
    index c485b80..9025f32 100644
    a b  
    11import unittest
    22
    33from django.apps import apps
    4 from django.test.utils import IgnoreAllDeprecationWarningsMixin
     4from django.test.utils import (IgnoreAllDeprecationWarningsMixin,
     5                               override_settings)
    56
    67
    78def suite():
    class SuiteOverrideTest(IgnoreAllDeprecationWarningsMixin, unittest.TestCase):  
    2425        suite = build_suite(app_config)
    2526        self.assertEqual(suite.countTestCases(), 1)
    2627
     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
    2741
    2842class SampleTests(unittest.TestCase):
    2943    """These tests should not be discovered, due to the custom suite."""
Back to Top