File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 27
27
import unittest
28
28
29
29
from test .support import check_disallow_instantiation , threading_helper , bigmemtest
30
- from test .support .os_helper import TESTFN , unlink
30
+ from test .support .os_helper import TESTFN , unlink , temp_dir
31
31
32
32
33
33
# Helper for tests using TESTFN
@@ -172,11 +172,12 @@ def test_module_constants(self):
172
172
173
173
def test_error_code_on_exception (self ):
174
174
err_msg = "unable to open database file"
175
- with self .assertRaisesRegex (sqlite .Error , err_msg ) as cm :
176
- sqlite .connect ("/no/such/file/exists" )
177
- e = cm .exception
178
- self .assertEqual (e .sqlite_errorcode , sqlite .SQLITE_CANTOPEN )
179
- self .assertEqual (e .sqlite_errorname , "SQLITE_CANTOPEN" )
175
+ with temp_dir () as db :
176
+ with self .assertRaisesRegex (sqlite .Error , err_msg ) as cm :
177
+ sqlite .connect (db )
178
+ e = cm .exception
179
+ self .assertEqual (e .sqlite_errorcode , sqlite .SQLITE_CANTOPEN )
180
+ self .assertEqual (e .sqlite_errorname , "SQLITE_CANTOPEN" )
180
181
181
182
# sqlite3_enable_shared_cache() is deprecated on macOS and calling it may raise
182
183
# OperationalError on some buildbots.
You can’t perform that action at this time.
0 commit comments