diff --git "a/tests/No\303\253l.jpg" "b/tests/No\303\253l.jpg" deleted file mode 100644 index 7a8aaf967..000000000 Binary files "a/tests/No\303\253l.jpg" and /dev/null differ diff --git a/tests/test_api.py b/tests/test_api.py index 41a910e3c..47f44330f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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