mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	gh-136289: Fix test_sqlite3 on platforms with strict UTF-8 filesystem (GH-136326)
This commit is contained in:
		
							parent
							
								
									9312702d2e
								
							
						
					
					
						commit
						85b817da94
					
				
					 1 changed files with 15 additions and 13 deletions
				
			
		|  | @ -31,8 +31,7 @@ | ||||||
| import warnings | import warnings | ||||||
| 
 | 
 | ||||||
| from test.support import ( | from test.support import ( | ||||||
|     SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess, |     SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess | ||||||
|     is_apple, is_emscripten, is_wasi |  | ||||||
| ) | ) | ||||||
| from test.support import gc_collect | from test.support import gc_collect | ||||||
| from test.support import threading_helper, import_helper | from test.support import threading_helper, import_helper | ||||||
|  | @ -641,14 +640,21 @@ def test_open_with_path_like_object(self): | ||||||
|             self.assertTrue(os.path.exists(path)) |             self.assertTrue(os.path.exists(path)) | ||||||
|             cx.execute(self._sql) |             cx.execute(self._sql) | ||||||
| 
 | 
 | ||||||
|     @unittest.skipIf(sys.platform == "win32", "skipped on Windows") |     def get_undecodable_path(self): | ||||||
|     @unittest.skipIf(is_apple, "skipped on Apple platforms") |  | ||||||
|     @unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI") |  | ||||||
|     @unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths") |  | ||||||
|     def test_open_with_undecodable_path(self): |  | ||||||
|         path = TESTFN_UNDECODABLE |         path = TESTFN_UNDECODABLE | ||||||
|  |         if not path: | ||||||
|  |             self.skipTest("only works if there are undecodable paths") | ||||||
|  |         try: | ||||||
|  |             open(path, 'wb').close() | ||||||
|  |         except OSError: | ||||||
|  |             self.skipTest(f"can't create file with undecodable path {path!r}") | ||||||
|  |         unlink(path) | ||||||
|  |         return path | ||||||
|  | 
 | ||||||
|  |     @unittest.skipIf(sys.platform == "win32", "skipped on Windows") | ||||||
|  |     def test_open_with_undecodable_path(self): | ||||||
|  |         path = self.get_undecodable_path() | ||||||
|         self.addCleanup(unlink, path) |         self.addCleanup(unlink, path) | ||||||
|         self.assertFalse(os.path.exists(path)) |  | ||||||
|         with contextlib.closing(sqlite.connect(path)) as cx: |         with contextlib.closing(sqlite.connect(path)) as cx: | ||||||
|             self.assertTrue(os.path.exists(path)) |             self.assertTrue(os.path.exists(path)) | ||||||
|             cx.execute(self._sql) |             cx.execute(self._sql) | ||||||
|  | @ -688,14 +694,10 @@ def test_open_uri_readonly(self): | ||||||
|                 cx.execute(self._sql) |                 cx.execute(self._sql) | ||||||
| 
 | 
 | ||||||
|     @unittest.skipIf(sys.platform == "win32", "skipped on Windows") |     @unittest.skipIf(sys.platform == "win32", "skipped on Windows") | ||||||
|     @unittest.skipIf(is_apple, "skipped on Apple platforms") |  | ||||||
|     @unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI") |  | ||||||
|     @unittest.skipUnless(TESTFN_UNDECODABLE, "only works if there are undecodable paths") |  | ||||||
|     def test_open_undecodable_uri(self): |     def test_open_undecodable_uri(self): | ||||||
|         path = TESTFN_UNDECODABLE |         path = self.get_undecodable_path() | ||||||
|         self.addCleanup(unlink, path) |         self.addCleanup(unlink, path) | ||||||
|         uri = "file:" + urllib.parse.quote(path) |         uri = "file:" + urllib.parse.quote(path) | ||||||
|         self.assertFalse(os.path.exists(path)) |  | ||||||
|         with contextlib.closing(sqlite.connect(uri, uri=True)) as cx: |         with contextlib.closing(sqlite.connect(uri, uri=True)) as cx: | ||||||
|             self.assertTrue(os.path.exists(path)) |             self.assertTrue(os.path.exists(path)) | ||||||
|             cx.execute(self._sql) |             cx.execute(self._sql) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka