summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwim glenn <wim.glenn@melbourneit.com.au>2015-06-05 19:36:30 +1000
committerwim glenn <wim.glenn@melbourneit.com.au>2015-06-05 19:36:30 +1000
commit3791004b4340276697aa1b9d45a6cd2976763529 (patch)
treeabd84b43175c84db322e01f72be7d3d4b92af683
parentdaaabb9aa8366c98c6fdb96b4b178c43e5be8fe9 (diff)
downloadisort-3791004b4340276697aa1b9d45a6cd2976763529.tar.gz
test gnarly encodings
-rw-r--r--test_isort.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test_isort.py b/test_isort.py
index d8467498..7bc84e4e 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -22,6 +22,11 @@ OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
+import codecs
+import os
+import shutil
+import tempfile
+
from pies.overrides import *
from isort.isort import SortImports
@@ -1329,3 +1334,15 @@ def test_fcntl():
"import sys\n")
assert SortImports(file_contents=test_input).output == test_input
+
+def test_other_file_encodings():
+ try:
+ tmp_dir = tempfile.mkdtemp()
+ for encoding in ('latin1', 'utf8'):
+ tmp_fname = os.path.join(tmp_dir, 'test_{}.py'.format(encoding))
+ with codecs.open(tmp_fname, mode='w', encoding=encoding) as f:
+ file_contents = "# coding: {}'\ns = u'\u00E3'".format(encoding)
+ f.write(file_contents)
+ assert SortImports(file_path=tmp_fname).output == file_contents
+ finally:
+ shutil.rmtree(tmp_dir, ignore_errors=True)