diff options
author | Seth Troisi <sethtroisi@google.com> | 2020-01-21 10:58:17 -0800 |
---|---|---|
committer | Seth Troisi <sethtroisi@google.com> | 2020-01-21 10:59:06 -0800 |
commit | 05a220dd9289d9c38ac22b9ffd7ca00830033e65 (patch) | |
tree | e5ec6c160e00df69772d6a6139470d532cab4816 /numpy | |
parent | 19b96a1635ee93c487d69ab88ac5ea3a6a14e79e (diff) | |
download | numpy-05a220dd9289d9c38ac22b9ffd7ca00830033e65.tar.gz |
TST: Simplify unicode test
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_unicode.py | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/numpy/core/tests/test_unicode.py b/numpy/core/tests/test_unicode.py index 686998aae..f16789148 100644 --- a/numpy/core/tests/test_unicode.py +++ b/numpy/core/tests/test_unicode.py @@ -4,9 +4,6 @@ import numpy as np from numpy.compat import unicode from numpy.testing import assert_, assert_equal, assert_array_equal -# Python 3.3+ uses a flexible string representation -ucs4 = False - def buffer_length(arr): if isinstance(arr, unicode): arr = str(arr) @@ -63,10 +60,7 @@ class CreateZeros: # Encode to ascii and double check assert_(ua_scalar.encode('ascii') == b'') # Check buffer lengths for scalars - if ucs4: - assert_(buffer_length(ua_scalar) == 0) - else: - assert_(buffer_length(ua_scalar) == 0) + assert_(buffer_length(ua_scalar) == 0) def test_zeros0D(self): # Check creation of 0-dimensional objects @@ -116,17 +110,14 @@ class CreateValues: assert_(ua_scalar.encode('utf-8') == (self.ucs_value*self.ulen).encode('utf-8')) # Check buffer lengths for scalars - if ucs4: - assert_(buffer_length(ua_scalar) == 4*self.ulen) + if self.ucs_value == ucs4_value: + # In UCS2, the \U0010FFFF will be represented using a + # surrogate *pair* + assert_(buffer_length(ua_scalar) == 2*2*self.ulen) else: - if self.ucs_value == ucs4_value: - # In UCS2, the \U0010FFFF will be represented using a - # surrogate *pair* - assert_(buffer_length(ua_scalar) == 2*2*self.ulen) - else: - # In UCS2, the \uFFFF will be represented using a - # regular 2-byte word - assert_(buffer_length(ua_scalar) == 2*self.ulen) + # In UCS2, the \uFFFF will be represented using a + # regular 2-byte word + assert_(buffer_length(ua_scalar) == 2*self.ulen) def test_values0D(self): # Check creation of 0-dimensional objects with values @@ -201,17 +192,14 @@ class AssignValues: assert_(ua_scalar.encode('utf-8') == (self.ucs_value*self.ulen).encode('utf-8')) # Check buffer lengths for scalars - if ucs4: - assert_(buffer_length(ua_scalar) == 4*self.ulen) + if self.ucs_value == ucs4_value: + # In UCS2, the \U0010FFFF will be represented using a + # surrogate *pair* + assert_(buffer_length(ua_scalar) == 2*2*self.ulen) else: - if self.ucs_value == ucs4_value: - # In UCS2, the \U0010FFFF will be represented using a - # surrogate *pair* - assert_(buffer_length(ua_scalar) == 2*2*self.ulen) - else: - # In UCS2, the \uFFFF will be represented using a - # regular 2-byte word - assert_(buffer_length(ua_scalar) == 2*self.ulen) + # In UCS2, the \uFFFF will be represented using a + # regular 2-byte word + assert_(buffer_length(ua_scalar) == 2*self.ulen) def test_values0D(self): # Check assignment of 0-dimensional objects with values |