1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

run black

This commit is contained in:
Ben Cail 2022-11-28 11:22:12 -05:00
parent f992997fbe
commit e9c7695a43
3 changed files with 12 additions and 7 deletions

View File

@ -168,7 +168,9 @@ class Settings:
except ImportError as exc:
# If the settings module cannot be imported, treat it as a configuration error.
if exc.name == self.SETTINGS_MODULE:
raise ImproperlyConfigured(f"Settings module {self.SETTINGS_MODULE} could not be imported") from exc
raise ImproperlyConfigured(
f"Settings module {self.SETTINGS_MODULE} could not be imported"
) from exc
raise
tuple_settings = (

View File

@ -383,8 +383,8 @@ class ManagementUtility:
except ImproperlyConfigured as exc:
self.settings_exception = exc
# The following commands can be run even without a valid settings file configured
if subcommand not in {'startproject', 'startapp', 'makemessages'}:
sys.stderr.write(str(exc) + '\n')
if subcommand not in {"startproject", "startapp", "makemessages"}:
sys.stderr.write(str(exc) + "\n")
self.settings_exception = exc
if settings.configured:

View File

@ -340,17 +340,20 @@ class SettingsTests(SimpleTestCase):
def test_unable_to_import_settings_module(self):
with self.assertRaisesMessage(
ImproperlyConfigured, "Settings module fake_settings_module could not be imported"
ImproperlyConfigured,
"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 mock_import_module(_):
raise ModuleNotFoundError("No module named 'fake_module'", name="fake_module")
raise ModuleNotFoundError(
"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'"):
Settings('fake_settings_module')
Settings("fake_settings_module")
class TestComplexSettingOverride(SimpleTestCase):