mirror of
https://github.com/django/django.git
synced 2025-04-19 06:44:36 +00:00
PR review
This commit is contained in:
parent
f87b23d8a1
commit
0bc79fc543
@ -385,7 +385,6 @@ class ManagementUtility:
|
||||
# The following commands can be run without a valid settings file configured
|
||||
if subcommand not in {"startproject", "startapp", "makemessages"}:
|
||||
sys.stderr.write(str(exc) + "\n")
|
||||
self.settings_exception = exc
|
||||
|
||||
if settings.configured:
|
||||
# Start the auto-reloading dev server even if the code is broken.
|
||||
|
@ -339,19 +339,13 @@ class SettingsTests(SimpleTestCase):
|
||||
settings._setup()
|
||||
|
||||
def test_unable_to_import_settings_module(self):
|
||||
with self.assertRaisesMessage(
|
||||
ImproperlyConfigured,
|
||||
"Settings module fake_settings_module could not be imported",
|
||||
):
|
||||
msg = "Settings module fake_settings_module could not be imported"
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
Settings("fake_settings_module")
|
||||
|
||||
def test_unable_to_import_a_random_module(self):
|
||||
def mock_import_module(_):
|
||||
raise ModuleNotFoundError(
|
||||
"No module named 'fake_module'", name="fake_module"
|
||||
)
|
||||
|
||||
with mock.patch("importlib.import_module", mock_import_module):
|
||||
exc = ModuleNotFoundError("No module named 'fake_module'", name="fake_module")
|
||||
with mock.patch("importlib.import_module", side_effect=exc):
|
||||
with self.assertRaisesMessage(ImportError, "No module named 'fake_module'"):
|
||||
Settings("fake_settings_module")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user