Skip to content

Commit 2c9c165

Browse files
committed
test: fix unsetenv not exists in earlier python on windows
1 parent da2a7bd commit 2c9c165

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test_qiniu.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ def test_invalid_x_qiniu_date_with_disable_date_sign(self):
285285
def test_invalid_x_qiniu_date_env(self):
286286
os.environ['DISABLE_QINIU_TIMESTAMP_SIGNATURE'] = 'True'
287287
ret, info = self.bucket.stat(bucket_name, 'python-sdk.html')
288-
os.unsetenv('DISABLE_QINIU_TIMESTAMP_SIGNATURE')
288+
if hasattr(os, 'unsetenv'):
289+
os.unsetenv('DISABLE_QINIU_TIMESTAMP_SIGNATURE')
290+
else:
291+
# fix unsetenv not exists in earlier python on windows
292+
os.environ['DISABLE_QINIU_TIMESTAMP_SIGNATURE'] = ''
289293
assert 'hash' in ret
290294

291295
@freeze_time("1970-01-01")
@@ -294,7 +298,11 @@ def test_invalid_x_qiniu_date_env_be_ignored(self):
294298
q = Auth(access_key, secret_key, disable_qiniu_timestamp_signature=False)
295299
bucket = BucketManager(q)
296300
ret, info = bucket.stat(bucket_name, 'python-sdk.html')
297-
os.unsetenv('DISABLE_QINIU_TIMESTAMP_SIGNATURE')
301+
if hasattr(os, 'unsetenv'):
302+
os.unsetenv('DISABLE_QINIU_TIMESTAMP_SIGNATURE')
303+
else:
304+
# fix unsetenv not exists in earlier python on windows
305+
os.environ['DISABLE_QINIU_TIMESTAMP_SIGNATURE'] = ''
298306
assert ret is None
299307
assert info.status_code == 403
300308

0 commit comments

Comments
 (0)