mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
Merge pull request #668 from spapas/fix-base-dir-path
Make sure BASE_DIR is a Path - fixesd #687
This commit is contained in:
commit
fa556d281c
2 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Dict, List, Tuple, Union
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -101,7 +102,8 @@ class AppSettings:
|
|||
|
||||
@property
|
||||
def DIRS(self) -> List[Union[str, Tuple[str, str]]]:
|
||||
return self.settings.get("dirs", [settings.BASE_DIR / "components"])
|
||||
base_dir_path = Path(settings.BASE_DIR)
|
||||
return self.settings.get("dirs", [base_dir_path / "components"])
|
||||
|
||||
@property
|
||||
def APP_DIRS(self) -> List[str]:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from pathlib import Path
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
from django_components.app_settings import app_settings
|
||||
|
@ -17,3 +19,11 @@ class SettingsTestCase(BaseTestCase):
|
|||
def test_raises_on_invalid_context_behavior(self):
|
||||
with self.assertRaises(ValueError):
|
||||
app_settings.CONTEXT_BEHAVIOR
|
||||
|
||||
@override_settings(BASE_DIR="base_dir")
|
||||
def test_works_when_base_dir_is_string(self):
|
||||
self.assertEqual(app_settings.DIRS, [Path("base_dir/components")])
|
||||
|
||||
@override_settings(BASE_DIR=Path("base_dir"))
|
||||
def test_works_when_base_dir_is_path(self):
|
||||
self.assertEqual(app_settings.DIRS, [Path("base_dir/components")])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue