diff options
author | wim glenn <wim.glenn@melbourneit.com.au> | 2015-06-05 19:36:30 +1000 |
---|---|---|
committer | wim glenn <wim.glenn@melbourneit.com.au> | 2015-06-05 19:36:30 +1000 |
commit | 3791004b4340276697aa1b9d45a6cd2976763529 (patch) | |
tree | abd84b43175c84db322e01f72be7d3d4b92af683 | |
parent | daaabb9aa8366c98c6fdb96b4b178c43e5be8fe9 (diff) | |
download | isort-3791004b4340276697aa1b9d45a6cd2976763529.tar.gz |
test gnarly encodings
-rw-r--r-- | test_isort.py | 17 |
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) |