Skip to content

Commit

Permalink
Skip if non-Unicode filesystem encoding. Fix #193
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Sep 14, 2014
1 parent 53d7410 commit 64ab5a5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/image_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
import codecs
import io
import os
import os.path
import shutil
import sys
import tempfile
import warnings

Expand All @@ -15,6 +17,23 @@
from wand.font import Font


try:
filesystem_encoding = sys.getfilesystemencoding()
except RuntimeError:
unicode_filesystem_encoding = False
else:
try:
codec_info = codecs.lookup(filesystem_encoding)
except LookupError:
unicode_filesystem_encoding = False
else:
unicode_filesystem_encoding = codec_info.name in (
'utf-8', 'utf-16', 'utf-16-be', 'utf-16-le',
'utf-32', 'utf-32-be', 'utf-32-le',
'mbcs' # for Windows
)


def test_empty_image():
with Image() as img:
assert img.size == (0,0)
Expand Down Expand Up @@ -58,6 +77,8 @@ def test_read_from_filename(fx_asset):
assert img.width == 402


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_read_from_unicode_filename(fx_asset, tmpdir):
"""https://github.com/dahlia/wand/issues/122"""
filename = '모나리자.jpg'
Expand Down Expand Up @@ -97,6 +118,8 @@ def test_new_from_filename(fx_asset):
Image(filename=str(fx_asset.join('not-exists.jpg')))


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_new_from_unicode_filename(fx_asset, tmpdir):
"""https://github.com/dahlia/wand/issues/122"""
filename = '모나리자.jpg'
Expand Down Expand Up @@ -155,6 +178,8 @@ def test_save_to_filename(fx_asset):
os.remove(savefile)


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_save_to_unicode_filename(fx_asset, tmpdir):
filename = '모나리자.jpg'
if not PY3:
Expand Down

0 comments on commit 64ab5a5

Please sign in to comment.