summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge ssize_t branch.Martin v. Löwis2006-02-151-1/+3
|
* Fix bug:Michael W. Hudson2005-10-211-0/+9
| | | | | | | | [ 1327110 ] wrong TypeError traceback in generator expressions by removing the code that can stomp on the users' TypeError raised by the iterable argument to ''.join() -- PySequence_Fast (now?) gives a perfectly reasonable message itself. Also, a couple of tests.
* Disable encoding/decoding test, if unicode is disabled.Walter Dörwald2005-07-281-19/+20
|
* * Beef-up tests for str.count().Raymond Hettinger2005-02-201-0/+28
| | | | * Speed-up str.count() by using memchr() to fly between first char matches.
* * Beef-up testing of str.__contains__() and str.find().Raymond Hettinger2005-02-201-0/+24
| | | | | | | | | | | | | | | | | | | * Speed-up "x in y" where x has more than one character. The existing code made excessive calls to the expensive memcmp() function. The new code uses memchr() to rapidly find a start point for memcmp(). In addition to knowing that the first character is a match, the new code also checks that the last character is a match. This significantly reduces the incidence of false starts (saving memcmp() calls and making quadratic behavior less likely). Improves the timings on: python -m timeit -r7 -s"x='a'*1000" "'ab' in x" python -m timeit -r7 -s"x='a'*1000" "'bc' in x" Once this code has proven itself, then string_find_internal() should refer to it rather than running its own version. Also, something similar may apply to unicode objects.
* SF bug #1054139: serious string hashing error in 2.4b1Raymond Hettinger2004-10-261-0/+9
| | | | | _PyString_Resize() readied strings for mutation but did not invalidate the cached hash value.
* test_bug1001011(): Verify thatTim Peters2004-08-271-5/+33
| | | | | | | | | s.join([t]) is t for (s, t) in (str, str), (unicode, unicode), and (str, unicode). For (unicode, str), verify that it's *not* t (the result is promoted to unicode instead). Also verify that when t is a subclass of str or unicode that "the right thing" happens.
* Move test_bug1001011() to string_tests.MixinStrUnicodeTest so thatWalter Dörwald2004-08-261-0/+19
| | | | | | it can be used for str and unicode. Drop the test for "".join([s]) is s because this is an implementation detail (and doesn't work for unicode)
* SF #989185: Drop unicode.iswide() and unicode.width() and addHye-Shik Chang2004-08-041-25/+0
| | | | | | | | | | | | unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w
* Add iswide() and width() method for UserString according as theHye-Shik Chang2004-06-041-0/+25
| | | | addition to unicode objects.
* [SF #866875] Add a specialized routine for one characterHye-Shik Chang2004-01-051-14/+55
| | | | separaters on str.split() and str.rsplit().
* Fix unicode.rsplit()'s bug that ignores separater on the end of string whenHye-Shik Chang2003-12-231-0/+2
| | | | using specialized splitter for 1 char sep.
* Add rsplit method for str and unicode builtin types.Hye-Shik Chang2003-12-151-0/+20
| | | | | SF feature request #801847. Original patch is written by Sean Reifschneider.
* Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger2003-11-261-3/+3
|
* SF bug #795506: Wrong handling of string format code for float values.Raymond Hettinger2003-08-271-0/+1
| | | | | | Adding missing support for '%F'. Will backport to 2.3.1.
* Whitespace normalization.Tim Peters2003-04-241-1/+0
|
* Attempt to make all the various string *strip methods the same.Neal Norwitz2003-04-101-28/+27
| | | | | | | | | | | * Doc - add doc for when functions were added * UserString * string object methods * string module functions 'chars' is used for the last parameter everywhere. These changes will be backported, since part of the changes have already been made, but they were inconsistent.
* Fix PyString_Format() so that '%c' % u'a' returns u'a'Walter Dörwald2003-03-311-0/+1
| | | | | | | | instead of raising a TypeError. (From SF patch #710127) Add tests to verify this is fixed. Add various tests for '%c' % int.
* Add two tests for simple error cases.Walter Dörwald2003-03-261-0/+4
|
* Get test to work on alphaNeal Norwitz2003-02-231-1/+1
|
* Port all string tests to PyUnit and share as much testsWalter Dörwald2003-02-211-317/+616
| | | | | | | between str, unicode, UserString and the string module as possible. This increases code coverage in stringobject.c from 83% to 86% and should help keep the string classes in sync in the future. From SF patch #662807
* Patch #650653: Raise always value error if the table is not 256 bytes long.Martin v. Löwis2002-12-121-0/+2
|
* check for str.__mod__Neil Schemenauer2002-11-181-0/+3
|
* Code by Inyeol Lee, submitted to SF bug 595350, to implementGuido van Rossum2002-08-231-0/+4
| | | | | the string/unicode method .replace() with a zero-lengt first argument. Inyeol contributed tests for this too.
* Moved inplace add and multiply methods from UserString to MutableString.Raymond Hettinger2002-08-091-0/+6
| | | | | Closes SF Bug #592573 where inplace add mutated a UserString. Added unittests to verify the bug is cleared.
* Revised the test suite for 'contains' to use the test() function argumentRaymond Hettinger2002-08-091-9/+9
| | | | | rather than vereq(). While it was effectively testing regular strings, it ignored the test() function argument when called by test_userstring.py.
* Whitespace normalization.Tim Peters2002-08-081-1/+0
|
* Committing patch #591250 which provides "str1 in str2" when str1 is aBarry Warsaw2002-08-061-1/+21
| | | | string of longer than 1 character.
* Complete the absolute import patch for the test suite. All relativeBarry Warsaw2002-07-301-1/+1
| | | | | | | | imports of test modules now import from the test package. Other related oddities are also fixed (like DeprecationWarning filters that weren't specifying the full import part, etc.). Also did a general code cleanup to remove all "from test.test_support import *"'s. Other from...import *'s weren't changed.
* SF bug # 493951 string.{starts,ends}with vs slicesNeal Norwitz2002-06-141-0/+27
| | | | Handle negative indices similar to slices.
* Whitespace normalization.Tim Peters2002-05-231-3/+3
|
* More --disable-unicode stuff.Michael W. Hudson2002-05-201-4/+9
| | | | I'm getting better at vi!
* Apply patch diff.txt from SF feature requestWalter Dörwald2002-04-221-1/+7
| | | | | | | | | http://www.python.org/sf/444708 This adds the optional argument for str.strip to unicode.strip too and makes it possible to call str.strip with a unicode argument and unicode.strip with a str argument.
* Whitespace normalization.Tim Peters2002-04-161-1/+1
|
* Apply the second version of SF patch http://www.python.org/sf/536241Walter Dörwald2002-04-151-0/+10
| | | | | | | | | | Add a method zfill to str, unicode and UserString and change Lib/string.py accordingly. This activates the zfill version in unicodeobject.c that was commented out and implements the same in stringobject.c. It also adds the test for unicode support in Lib/string.py back in and uses repr() instead() of str() (as it was before Lib/string.py 1.62)
* Partially implement SF feature request 444708.Guido van Rossum2002-04-131-0/+12
| | | | | | | | | | | | | Add optional arg to string methods strip(), lstrip(), rstrip(). The optional arg specifies characters to delete. Also for UserString. Still to do: - Misc/NEWS - LaTeX docs (I did the docstrings though) - Unicode methods, and Unicode support in the string methods.
* Add two tests for string.zfillAndrew M. Kuchling2002-03-291-0/+3
|
* Patch #445762: Support --disable-unicodeMartin v. Löwis2001-08-171-6/+7
| | | | | | | | - Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
* This patch changes the way the string .encode() method works slightlyMarc-André Lemburg2001-05-151-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | and introduces a new method .decode(). The major change is that strg.encode() will no longer try to convert Unicode returns from the codec into a string, but instead pass along the Unicode object as-is. The same is now true for all other codec return types. The underlying C APIs were changed accordingly. Note that even though this does have the potential of breaking existing code, the chances are low since conversion from Unicode previously took place using the default encoding which is normally set to ASCII rendering this auto-conversion mechanism useless for most Unicode encodings. The good news is that you can now use .encode() and .decode() with much greater ease and that the door was opened for better accessibility of the builtin codecs. As demonstration of the new feature, the patch includes a few new codecs which allow string to string encoding and decoding (rot13, hex, zip, uu, base64). Written by Marc-Andre Lemburg. Copyright assigned to the PSF.
* SF bug #422088: [OSF1 alpha] string.replace().Tim Peters2001-05-091-0/+6
| | | | | | Platform blew up on "123".replace("123", ""). Michael Hudson pinned the blame on platform malloc(0) returning NULL. This is a candidate for all bugfix releases.
* String method conversion.Eric S. Raymond2001-02-091-2/+2
|
* Fixed .capitalize() method of Unicode objects to work like theMarc-André Lemburg2001-01-291-0/+2
| | | | | | corresponding string method. Added tests for this too. Patch written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
* Whitespace normalization. Leaving tokenize_tests.py alone for now.Tim Peters2001-01-181-1/+1
|
* Added checks to prevent PyUnicode_Count() from dumping coreMarc-André Lemburg2001-01-161-0/+4
| | | | | | | | | | | | in case the parameters are out of bounds and fixes error handling for .count(), .startswith() and .endswith() for the case of mixed string/Unicode objects. This patch adds Python style index semantics to PyUnicode_Count() indices (including the special handling of negative indices). The patch is an extended version of patch #103249 submitted by Michael Hudson (mwh) on SF. It also includes new test cases.
* small updates to string_join:Jeremy Hylton2000-07-111-0/+3
| | | | | | | use PyString_AS_STRING macro on local string object when resizing string, make sure resized string will always be big enough split string containing error message across two lines add test to string_tests that causes resizing
* add more tests of string.join variants to run_method_testsJeremy Hylton2000-07-111-8/+11
|
* factor out test definitions to string_tests moduleJeremy Hylton2000-07-101-0/+196
test_string and test_userstring run same tests for string methods