Check unidata_version to determine width

Did not actually determine whether this check is correct.
This commit is contained in:
Foo 2017-08-06 02:34:40 +03:00
parent b047abcd9a
commit 335be73d3e
1 changed files with 10 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import os
import sys
import re
import shutil
import unicodedata
from time import sleep
from subprocess import call, PIPE
@ -429,6 +430,13 @@ width_data = {
'F': 2, # Fullwidth
}
unidata_version = tuple((
int(c) for c in unicodedata.unidata_version.split('.')))
U1F48E_WIDTH = (
1 if unidata_version >= (6,) else 2
)
class TestUnicode(TestCase):
def assertStringsIdentical(self, s1, s2):
@ -497,14 +505,14 @@ class TestUnicode(TestCase):
if sys.maxunicode < 0x10FFFF:
raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons')
self.assertEqual(1, plu.strwidth_ucs_4(width_data, '\U0001F48E'))
self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_4(width_data, '\U0001F48E'))
def test_strwidth_ucs_2(self):
self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'abcd'))
self.assertEqual(4, plu.strwidth_ucs_2(width_data, ''))
if not sys.maxunicode < 0x10FFFF:
raise SkipTest('Can only test strwidth_ucs_2 in UCS-2 Pythons')
self.assertEqual(1, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e'))
self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e'))
class TestVCS(TestCase):