summaryrefslogtreecommitdiff
path: root/Lib/test/test_sqlite3/test_dbapi.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-05-20 11:53:05 +0300
committerGitHub <noreply@github.com>2022-05-20 11:53:05 +0300
commitd8537580921b2e02f477ff1a8dedcf82c24ef0c2 (patch)
tree6f4d48893407cdbcf9d99fa6083c470995a6334a /Lib/test/test_sqlite3/test_dbapi.py
parent0e12781ad9dec6e46ccb85969c0eb7be1ecad81d (diff)
downloadcpython-git-d8537580921b2e02f477ff1a8dedcf82c24ef0c2.tar.gz
gh-91922: Fix sqlite connection on nonstardard locales and paths (GH-92926)
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 8a21897379..40f91a193b 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -21,21 +21,19 @@
# 3. This notice may not be removed or altered from any source distribution.
import contextlib
+import os
import sqlite3 as sqlite
import subprocess
import sys
import threading
import unittest
+import urllib.parse
-from test.support import (
- SHORT_TIMEOUT,
- bigmemtest,
- check_disallow_instantiation,
- threading_helper,
-)
+from test.support import SHORT_TIMEOUT, bigmemtest, check_disallow_instantiation
+from test.support import threading_helper
from _testcapi import INT_MAX, ULLONG_MAX
from os import SEEK_SET, SEEK_CUR, SEEK_END
-from test.support.os_helper import TESTFN, unlink, temp_dir
+from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE, unlink, temp_dir, FakePath
# Helper for tests using TESTFN
@@ -654,11 +652,19 @@ class OpenTests(unittest.TestCase):
def test_open_with_path_like_object(self):
""" Checks that we can successfully connect to a database using an object that
is PathLike, i.e. has __fspath__(). """
- class Path:
- def __fspath__(self):
- return TESTFN
- path = Path()
+ path = FakePath(TESTFN)
with managed_connect(path) as cx:
+ self.assertTrue(os.path.exists(path))
+ cx.execute(self._sql)
+
+ @unittest.skipIf(sys.platform == "win32", "skipped on Windows")
+ @unittest.skipIf(sys.platform == "darwin", "skipped on macOS")
+ @unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths")
+ def test_open_with_undecodable_path(self):
+ self.addCleanup(unlink, TESTFN_UNDECODABLE)
+ path = TESTFN_UNDECODABLE
+ with managed_connect(path) as cx:
+ self.assertTrue(os.path.exists(path))
cx.execute(self._sql)
def test_open_uri(self):