@@ -118,6 +118,7 @@ def test_1703286_B(self):
118
118
@unittest .skipUnless (os .name == "nt" ,
119
119
'test specific to Windows' )
120
120
def test_load_dll_with_flags (self ):
121
+ import nt
121
122
_sqlite3 = test .support .import_module ("_sqlite3" )
122
123
src = _sqlite3 .__file__
123
124
if src .lower ().endswith ("_d.pyd" ):
@@ -139,17 +140,25 @@ def should_pass(command):
139
140
with self .subTest (command ):
140
141
subprocess .check_output (
141
142
[sys .executable , "-c" ,
142
- "from ctypes import *; import nt;" + command ],
143
- cwd = tmp
143
+ "; " .join ([
144
+ "import nt" ,
145
+ "nt.chdir({!r})" .format (tmp ),
146
+ "from ctypes import *" ,
147
+ command
148
+ ])]
144
149
)
145
150
146
151
def should_fail (command ):
147
152
with self .subTest (command ):
148
153
with self .assertRaises (subprocess .CalledProcessError ):
149
154
subprocess .check_output (
150
155
[sys .executable , "-c" ,
151
- "from ctypes import *; import nt;" + command ],
152
- cwd = tmp , stderr = subprocess .STDOUT ,
156
+ "; " .join ([
157
+ "import nt" ,
158
+ "nt.chdir({!r})" .format (tmp ),
159
+ "from ctypes import *" ,
160
+ command
161
+ ])], stderr = subprocess .STDOUT ,
153
162
)
154
163
155
164
# Default load should not find this in CWD
@@ -162,11 +171,11 @@ def should_fail(command):
162
171
should_pass ("WinDLL('_sqlite3.dll', winmode=0)" )
163
172
164
173
# Full path load without DLL_LOAD_DIR shouldn't find dependency
165
- should_fail ("WinDLL(nt._getfullpathname('_sqlite3.dll') , " +
174
+ should_fail ("WinDLL({!r} , " . format ( target ) +
166
175
"winmode=nt._LOAD_LIBRARY_SEARCH_SYSTEM32)" )
167
176
168
177
# Full path load with DLL_LOAD_DIR should succeed
169
- should_pass ("WinDLL(nt._getfullpathname('_sqlite3.dll') , " +
178
+ should_pass ("WinDLL({!r} , " . format ( target ) +
170
179
"winmode=nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)" )
171
180
172
181
# User-specified directory should succeed
0 commit comments