class BaseStrTest:
- @bigmemtest(size=_2G, memuse=2)
- def test_capitalize(self, size):
+ def _test_capitalize(self, size):
_ = self.from_latin1
SUBSTR = self.from_latin1(' abc def ghi')
s = _('-') * size + SUBSTR
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(size=_2G, memuse=2)
- def test_swapcase(self, size):
+ def _test_swapcase(self, size):
_ = self.from_latin1
SUBSTR = _("aBcDeFG12.'\xa9\x00")
sublen = len(SUBSTR)
self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
- @bigmemtest(size=_2G, memuse=2)
- def test_title(self, size):
+ def _test_title(self, size):
_ = self.from_latin1
SUBSTR = _('SpaaHAaaAaham')
s = SUBSTR * (size // len(SUBSTR) + 2)
for name, memuse in self._adjusted.items():
getattr(type(self), name).memuse = memuse
+ @bigmemtest(size=_2G, memuse=ucs4_char_size * 3)
+ def test_capitalize(self, size):
+ self._test_capitalize(size)
+
+ @bigmemtest(size=_2G, memuse=ucs4_char_size * 3)
+ def test_title(self, size):
+ self._test_title(size)
+
+ @bigmemtest(size=_2G, memuse=ucs4_char_size * 3)
+ def test_swapcase(self, size):
+ self._test_swapcase(size)
+
# Many codecs convert to the legacy representation first, explaining
# why we add 'ucs4_char_size' to the 'memuse' below.
s = self.from_latin1('.') * size
self.assertEqual(len(s.decode('utf-8')), size)
+ @bigmemtest(size=_2G, memuse=2)
+ def test_capitalize(self, size):
+ self._test_capitalize(size)
+
+ @bigmemtest(size=_2G, memuse=2)
+ def test_title(self, size):
+ self._test_title(size)
+
+ @bigmemtest(size=_2G, memuse=2)
+ def test_swapcase(self, size):
+ self._test_swapcase(size)
+
class BytearrayTest(unittest.TestCase, BaseStrTest):
s = self.from_latin1('.') * size
self.assertEqual(len(s.decode('utf-8')), size)
+ @bigmemtest(size=_2G, memuse=2)
+ def test_capitalize(self, size):
+ self._test_capitalize(size)
+
+ @bigmemtest(size=_2G, memuse=2)
+ def test_title(self, size):
+ self._test_title(size)
+
+ @bigmemtest(size=_2G, memuse=2)
+ def test_swapcase(self, size):
+ self._test_swapcase(size)
+
test_hash = None
test_split_large = None
{
if (PyUnicode_READY(self) == -1)
return NULL;
- return case_operation(self, do_title);
+ if (PyUnicode_IS_ASCII(self))
+ return ascii_case_operation(self, ascii_do_title);
+ else
+ return case_operation(self, do_title);
}
PyDoc_STRVAR(capitalize__doc__,
return NULL;
if (PyUnicode_GET_LENGTH(self) == 0)
return unicode_result_unchanged(self);
- return case_operation(self, do_capitalize);
+ if (PyUnicode_IS_ASCII(self))
+ return ascii_case_operation(self, ascii_do_capitalize);
+ else
+ return case_operation(self, do_capitalize);
}
PyDoc_STRVAR(casefold__doc__,
return NULL;
if (PyUnicode_IS_ASCII(self))
return ascii_upper_or_lower(self, 1);
- return case_operation(self, do_casefold);
+ else
+ return case_operation(self, do_casefold);
}
return NULL;
if (PyUnicode_IS_ASCII(self))
return ascii_upper_or_lower(self, 1);
- return case_operation(self, do_lower);
+ else
+ return case_operation(self, do_lower);
}
#define LEFTSTRIP 0
{
if (PyUnicode_READY(self) == -1)
return NULL;
- return case_operation(self, do_swapcase);
+ if (PyUnicode_IS_ASCII(self))
+ return ascii_case_operation(self, ascii_do_swapcase);
+ else
+ return case_operation(self, do_swapcase);
}
PyDoc_STRVAR(maketrans__doc__,
return NULL;
if (PyUnicode_IS_ASCII(self))
return ascii_upper_or_lower(self, 0);
- return case_operation(self, do_upper);
+ else
+ return case_operation(self, do_upper);
}
PyDoc_STRVAR(zfill__doc__,