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