8000 gh-136289: Fix test_sqlite3 on platforms with strict UTF-8 filesystem… · python/cpython@85b817d · GitHub
[go: up one dir, main page]

Skip to content

Commit 85b817d

Browse files
gh-136289: Fix test_sqlite3 on platforms with strict UTF-8 filesystem (GH-136326)
1 parent 9312702 commit 85b817d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Lib/test/test_sqlite3/test_dbapi.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
import warnings
3232

3333
from test.support import (
34-
SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess,
35-
is_apple, is_emscripten, is_wasi
34+
SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess
3635
)
3736
from test.support import gc_collect
3837
from test.support import threading_helper, import_helper
@@ -641,14 +640,21 @@ def test_open_with_path_like_object(self):
641640
self.assertTrue(os.path.exists(path))
642641
cx.execute(self._sql)
643642

643+
def get_undecodable_path(self):
644+
path = TESTFN_UNDECODABLE
645+
if not path:
646+
self.skipTest("only works if there are undecodable paths")
647+
try:
648+
open(path, 'wb').close()
649+
except OSError:
650+
self.skipTest(f"can't create file with undecodable path {path!r}")
651+
unlink(path)
652+
return path
653+
644654
@unittest.skipIf(sys.platform == "win32", "skipped on Windows")
645-
@unittest.skipIf(is_apple, "skipped on Apple platforms")
646-
@unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI")
647-
@unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths")
648655
def test_open_with_undecodable_path(self):
649-
path = TESTFN_UNDECODABLE
656+
path = self.get_undecodable_path()
650657
self.addCleanup(unlink, path)
651-
self.assertFalse(os.path.exists(path))
652658
with contextlib.closing(sqlite.connect(path)) as cx:
653659
self.assertTrue(os.path.exists(path))
654660
cx.execute(self._sql)
@@ -688,14 +694,10 @@ def test_open_uri_readonly(self):
688694
cx.execute(self._sql)
689695

690696
@unittest.skipIf(sys.platform == "win32", "skipped on Windows")
691-
@unittest.skipIf(is_apple, "skipped on Apple platforms")
692-
@unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI")
693-
@unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths")
694697
def test_open_undecodable_uri(self):
695-
path = TESTFN_UNDECODABLE
698+
path = self.get_undecodable_path()
696699
self.addCleanup(unlink, path)
697700
uri = "file:" + urllib.parse.quote(path)
698-
self.assertFalse(os.path.exists(path))
699701
with contextlib.closing(sqlite.connect(uri, uri=True)) as cx:
700702
self.assertTrue(os.path.exists(path))
701703
cx.execute(self._sql)

0 commit comments

Comments
 (0)
0