-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34b786b
commit 9b28238
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from __future__ import unicode_literals | ||
|
||
import sys | ||
import pytest | ||
|
||
from fontTools.misc.py23 import unicode, tounicode, tobytes, tostr | ||
|
||
|
||
def test_fontv_fonttools_lib_unicode(): | ||
test_string = tobytes("hello") | ||
test_string_str = tostr("hello") | ||
test_string_unicode = tounicode(test_string, 'utf-8') | ||
test_string_str_unicode = tounicode(test_string_str, 'utf-8') | ||
|
||
assert (isinstance(test_string, unicode)) is False | ||
if sys.version_info[0] == 2: | ||
assert (isinstance(test_string_str, unicode)) is False # str != unicode in Python 2 | ||
elif sys.version_info[0] == 3: | ||
assert (isinstance(test_string_str, unicode)) is True # str = unicode in Python 3 | ||
assert (isinstance(test_string_unicode, unicode)) is True # after cast with fonttools function, Py2+3 = unicode | ||
assert (isinstance(test_string_str_unicode, unicode)) is True # ditto | ||
assert test_string_unicode == "hello" |