mirror of
https://github.com/django/django.git
synced 2025-09-12 05:26:27 +00:00
Refs #29983 -- Added support for using pathlib.Path in all settings.
This commit is contained in:
parent
367634f976
commit
77aa74cb70
18 changed files with 118 additions and 10 deletions
|
@ -1,11 +1,14 @@
|
|||
import os
|
||||
import re
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from sqlite3 import dbapi2
|
||||
from unittest import mock
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import connection, transaction
|
||||
from django.db import ConnectionHandler, connection, transaction
|
||||
from django.db.models import Avg, StdDev, Sum, Variance
|
||||
from django.db.models.aggregates import Aggregate
|
||||
from django.db.models.fields import CharField
|
||||
|
@ -89,6 +92,19 @@ class Tests(TestCase):
|
|||
value = bool(value) if value in {0, 1} else value
|
||||
self.assertIs(value, expected)
|
||||
|
||||
def test_pathlib_name(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
settings_dict = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': Path(tmp) / 'test.db',
|
||||
},
|
||||
}
|
||||
connections = ConnectionHandler(settings_dict)
|
||||
connections['default'].ensure_connection()
|
||||
connections['default'].close()
|
||||
self.assertTrue(os.path.isfile(os.path.join(tmp, 'test.db')))
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
|
||||
@isolate_apps('backends')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue