diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-07 01:26:22 -0800 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-11-07 10:26:22 +0100 |
| commit | 77aa74cb70dd85497dbade6bc0f394aa41e88c94 (patch) | |
| tree | f526b5e63897415e8753c6e38396bba535e3fc75 /tests/backends/sqlite | |
| parent | 367634f976ab43db93321bf4eb898449b670e291 (diff) | |
Refs #29983 -- Added support for using pathlib.Path in all settings.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index 21be45fb11..3447fb6096 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -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') |
