|
31 | 31 | import warnings
|
32 | 32 |
|
33 | 33 | 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 |
36 | 35 | )
|
37 | 36 | from test.support import gc_collect
|
38 | 37 | from test.support import threading_helper, import_helper
|
@@ -641,14 +640,21 @@ def test_open_with_path_like_object(self):
|
641 | 640 | self.assertTrue(os.path.exists(path))
|
642 | 641 | cx.execute(self._sql)
|
643 | 642 |
|
| 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 | + |
644 | 654 | @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") |
648 | 655 | def test_open_with_undecodable_path(self):
|
649 |
| - path = TESTFN_UNDECODABLE |
| 656 | + path = self.get_undecodable_path() |
650 | 657 | self.addCleanup(unlink, path)
|
651 |
| - self.assertFalse(os.path.exists(path)) |
652 | 658 | with contextlib.closing(sqlite.connect(path)) as cx:
|
653 | 659 | self.assertTrue(os.path.exists(path))
|
654 | 660 | cx.execute(self._sql)
|
@@ -688,14 +694,10 @@ def test_open_uri_readonly(self):
|
688 | 694 | cx.execute(self._sql)
|
689 | 695 |
|
690 | 696 | @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") |
694 | 697 | def test_open_undecodable_uri(self):
|
695 |
| - path = TESTFN_UNDECODABLE |
| 698 | + path = self.get_undecodable_path() |
696 | 699 | self.addCleanup(unlink, path)
|
697 | 700 | uri = "file:" + urllib.parse.quote(path)
|
698 |
| - self.assertFalse(os.path.exists(path)) |
699 | 701 | with contextlib.closing(sqlite.connect(uri, uri=True)) as cx:
|
700 | 702 | self.assertTrue(os.path.exists(path))
|
701 | 703 | cx.execute(self._sql)
|
|
0 commit comments