Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed tests/Noël.jpg
Binary file not shown.
33 changes: 28 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,34 @@ def test_upload_download(self):
self.assertRaises(TypeError, self.sg.download_attachment)

# test upload of non-ascii, unicode path
u_path = os.path.abspath(
os.path.expanduser(
glob.glob(os.path.join(six.text_type(this_dir), u'No*l.jpg'))[0]
)
)
s_path = os.path.join(this_dir, 'No\xc3\xabl.jpg')
u_path = s_path.decode("utf-8")
if sys.platform.startswith("win"):
fh = open(u_path, "wb")
else:
fh = open(s_path, "wb")

try:
buffer = b'\xff\xd8\xff\xdb\x00\x84\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01' \
b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' \
b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01' \
b'\x01\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x03\x03\x03' \
b'\x03\x03\x03\x03\x03\x03\x03\x01\x01\x01\x01\x01\x01\x01\x02\x01' \
b'\x01\x02\x02\x02\x01\x02\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03' \
b'\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03' \
b'\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03' \
b'\x03\x03\x03\x03\x03\x03\x03\x03\xff\xdd\x00\x04\x00\x01\xff\xee' \
b'\x00\x0eAdobe\x00d\xc0\x00\x00\x00\x01\xff\xc0\x00\x11\x08\x00\x02' \
b'\x00\x02\x03\x00\x11\x00\x01\x11\x01\x02\x11\x01\xff\xc4\x00J\x00' \
b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n' \
b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
b'\x00\x00\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
b'\x00\x00\x00\x00\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
b'\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x00\x00\x01\x11\x02' \
b'\x11\x00?\x00\x7f\x00\xff\xd9'
fh.write(buffer)
finally:
fh.close()

# If this is a problem, it'll raise with a UnicodeEncodeError. We
# don't need to check the results of the upload itself -- we're
Expand Down