mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +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:
parent
9b3389b726
commit
2b56d69102
3 changed files with 117 additions and 32 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue