mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Implemented two-stage app-cache population.
First stage imports app modules. It doesn't catch import errors. This matches the previous behavior and keeps the code simple. Second stage import models modules. It catches import errors and retries them after walking through the entire list once. This matches the previous behavior and seems useful. populate_models() is intended to be equivalent to populate(). It isn't wired yet. That is coming in the next commit.
This commit is contained in:
@@ -3,7 +3,6 @@ Tests for django test runner
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
from optparse import make_option
|
||||
import types
|
||||
import unittest
|
||||
@@ -227,10 +226,8 @@ class ModulesTestsPackages(IgnoreAllDeprecationWarningsMixin, unittest.TestCase)
|
||||
"Check that the get_tests helper function can find tests in a directory"
|
||||
from django.core.apps.base import AppConfig
|
||||
from django.test.simple import get_tests
|
||||
app_config = AppConfig(
|
||||
'test_runner.valid_app',
|
||||
import_module('test_runner.valid_app'),
|
||||
import_module('test_runner.valid_app.models'))
|
||||
app_config = AppConfig('test_runner.valid_app')
|
||||
app_config.import_models({})
|
||||
tests = get_tests(app_config)
|
||||
self.assertIsInstance(tests, types.ModuleType)
|
||||
|
||||
@@ -238,11 +235,10 @@ class ModulesTestsPackages(IgnoreAllDeprecationWarningsMixin, unittest.TestCase)
|
||||
"Test for #12658 - Tests with ImportError's shouldn't fail silently"
|
||||
from django.core.apps.base import AppConfig
|
||||
from django.test.simple import get_tests
|
||||
app_config = AppConfig(
|
||||
'test_runner_invalid_app',
|
||||
import_module('test_runner_invalid_app'),
|
||||
import_module('test_runner_invalid_app.models'))
|
||||
self.assertRaises(ImportError, get_tests, app_config)
|
||||
app_config = AppConfig('test_runner_invalid_app')
|
||||
app_config.import_models({})
|
||||
with self.assertRaises(ImportError):
|
||||
get_tests(app_config)
|
||||
|
||||
|
||||
class Sqlite3InMemoryTestDbs(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user