Check unidata_version to determine width
Did not actually determine whether this check is correct.
This commit is contained in:
parent
b047abcd9a
commit
335be73d3e
|
@ -6,6 +6,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from subprocess import call, PIPE
|
from subprocess import call, PIPE
|
||||||
|
@ -429,6 +430,13 @@ width_data = {
|
||||||
'F': 2, # Fullwidth
|
'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):
|
class TestUnicode(TestCase):
|
||||||
def assertStringsIdentical(self, s1, s2):
|
def assertStringsIdentical(self, s1, s2):
|
||||||
|
@ -497,14 +505,14 @@ class TestUnicode(TestCase):
|
||||||
if sys.maxunicode < 0x10FFFF:
|
if sys.maxunicode < 0x10FFFF:
|
||||||
raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons')
|
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):
|
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, 'abcd'))
|
||||||
self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'AB'))
|
self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'AB'))
|
||||||
if not sys.maxunicode < 0x10FFFF:
|
if not sys.maxunicode < 0x10FFFF:
|
||||||
raise SkipTest('Can only test strwidth_ucs_2 in UCS-2 Pythons')
|
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):
|
class TestVCS(TestCase):
|
||||||
|
|
Loading…
Reference in New Issue