mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #33949 -- Fixed fixture dirs duplicates with Path instances.
This commit is contained in:
parent
7e6b537f5b
commit
903ac2f364
@ -367,7 +367,7 @@ class Command(BaseCommand):
|
||||
for app_config in apps.get_app_configs():
|
||||
app_label = app_config.label
|
||||
app_dir = os.path.join(app_config.path, "fixtures")
|
||||
if app_dir in fixture_dirs:
|
||||
if app_dir in [str(d) for d in fixture_dirs]:
|
||||
raise ImproperlyConfigured(
|
||||
"'%s' is a default fixture directory for the '%s' app "
|
||||
"and cannot be listed in settings.FIXTURE_DIRS."
|
||||
|
@ -569,6 +569,20 @@ class TestFixtures(TestCase):
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
management.call_command("loaddata", "absolute.json", verbosity=0)
|
||||
|
||||
@override_settings(FIXTURE_DIRS=[Path(_cur_dir) / "fixtures"])
|
||||
def test_fixture_dirs_with_default_fixture_path_as_pathlib(self):
|
||||
"""
|
||||
settings.FIXTURE_DIRS cannot contain a default fixtures directory
|
||||
for application (app/fixtures) in order to avoid repeated fixture loading.
|
||||
"""
|
||||
msg = (
|
||||
"'%s' is a default fixture directory for the '%s' app "
|
||||
"and cannot be listed in settings.FIXTURE_DIRS."
|
||||
% (os.path.join(_cur_dir, "fixtures"), "fixtures_regress")
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
management.call_command("loaddata", "absolute.json", verbosity=0)
|
||||
|
||||
@override_settings(
|
||||
FIXTURE_DIRS=[
|
||||
os.path.join(_cur_dir, "fixtures_1"),
|
||||
|
Loading…
Reference in New Issue
Block a user