Skip to content

Commit b4901d1

Browse files
committed
fix_tempfile_path
1 parent 79c54c7 commit b4901d1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

qiniu/test/resumable_io_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import unittest
44
import string
55
import random
6+
import platform
67
try:
78
import zlib as binascii
89
except ImportError:
@@ -52,7 +53,11 @@ def test_block(self):
5253

5354
def test_put(self):
5455
src = urllib.urlopen("http://cheneya.qiniudn.com/hello_jpg")
55-
tmpf = os.tmpnam()
56+
ostype = platform.system()
57+
if ostype.lower().find('windows'):
58+
tmpf = "".join([os.getcwd(), os.tmpnam()])
59+
else:
60+
tmpf = os.tmpnam()
5661
dst = open(tmpf, 'wb')
5762
shutil.copyfileobj(src, dst)
5863
src.close()
@@ -64,7 +69,7 @@ def test_put(self):
6469
localfile = dst.name
6570
ret, err = resumable_io.put_file(policy.token(), key, localfile, extra)
6671
dst.close()
67-
os.remove(tmpf)
72+
os.remove(tmpf)
6873

6974
assert err is None, err
7075
self.assertEqual(ret["hash"], "FnyTMUqPNRTdk1Wou7oLqDHkBm_p", "hash not match")

0 commit comments

Comments
 (0)