|
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
|
@@ -671,14 +670,21 @@ def test_open_with_path_like_object(self):
|
671 | 670 | self.assertTrue(os.path.exists(path))
|
672 | 671 | cx.execute(self._sql)
|
673 | 672 |
|
| 673 | + def get_undecodable_path(self): |
| 674 | + path = TESTFN_UNDECODABLE |
| 675 | + if not path: |
| 676 | + self.skipTest("only works if there are undecodable paths") |
| 677 | + try: |
| 678 | + open(path, 'wb').close() |
| 679 | + except OSError: |
| 680 | + self.skipTest(f"can't create file with undecodable path {path!r}") |
| 681 | + unlink(path) |
| 682 | + return path |
| 683 | + |
674 | 684 | @unittest.skipIf(sys.platform == "win32", "skipped on Windows")
|
675 |
| - @unittest.skipIf(is_apple, "skipped on Apple platforms") |
676 |
| - @unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI") |
677 |
| - @unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths") |
678 | 685 | def test_open_with_undecodable_path(self):
|
679 |
| - path = TESTFN_UNDECODABLE |
| 686 | + path = self.get_undecodable_path() |
680 | 687 | self.addCleanup(unlink, path)
|
681 |
| - self.assertFalse(os.path.exists(path)) |
682 | 688 | with contextlib.closing(sqlite.connect(path)) as cx:
|
683 | 689 | self.assertTrue(os.path.exists(path))
|
684 | 690 | cx.execute(self._sql)
|
@@ -718,14 +724,10 @@ def test_open_uri_readonly(self):
|
718 | 724 | cx.execute(self._sql)
|
719 | 725 |
|
720 | 726 | @unittest.skipIf(sys.platform == "win32", "skipped on Windows")
|
721 |
| - @unittest.skipIf(is_apple, "skipped on Apple platforms") |
722 |
| - @unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI") |
723 |
| - @unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths") |
724 | 727 | def test_open_undecodable_uri(self):
|
725 |
| - path = TESTFN_UNDECODABLE |
| 728 | + path = self.get_undecodable_path() |
726 | 729 | self.addCleanup(unlink, path)
|
727 | 730 | uri = "file:" + urllib.parse.quote(path)
|
728 |
| - self.assertFalse(os.path.exists(path)) |
729 | 731 | with contextlib.closing(sqlite.connect(uri, uri=True)) as cx:
|
730 | 732 | self.assertTrue(os.path.exists(path))
|
731 | 733 | cx.execute(self._sql)
|
|
0 commit comments