diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-10-22 20:24:51 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-10-22 20:24:51 (GMT) |
commit | 4043001f5d84d4919781e34221449047d0690ac8 (patch) | |
tree | 4b4db9f0b748407480aff4f10b99ce70548bfee0 /Lib/test/test_str.py | |
parent | 6464d471950c6ee109f82597ff70d755c127074f (diff) | |
download | cpython-4043001f5d84d4919781e34221449047d0690ac8.zip cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.gz cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.bz2 |
Make str/str8 comparisons return True/False for !=/==.
Code that has been returning str8 becomes much more apparent thanks to this
(e.g., struct module returning str8 for all string-related formats or sqlite3
passing in str8 instances when converting objects that had a __conform__
method). One also has to watch out in C code when making a key from char *
using PyString in the C code but a str instance in Python code as that will not
longer compare equal.
Once str8 gains a constructor like the current bytes type then
test_modulefinder needs a cleanup as the fix is a little messy in that file.
Thanks goes to Thomas Lee for writing the patch for the change giving an
initial run-down of why most of the tests were failing.
Diffstat (limited to 'Lib/test/test_str.py')
-rw-r--r-- | Lib/test/test_str.py | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index ad118d6..1d02467 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -36,34 +36,9 @@ class StrTest( def __str__(self): return "foo" - class Foo2(object): - def __str__(self): - return "foo" - - class Foo3(object): - def __str__(self): - return "foo" - - class Foo4(str8): - def __str__(self): - return "foo" - - class Foo5(str): - def __unicode__(self): - return "foo" - - class Foo6(str8): - def __str__(self): - return "foos" - - def __unicode__(self): - return "foou" - class Foo7(str): def __str__(self): return "foos" - def __unicode__(self): - return "foou" class Foo8(str): def __new__(cls, content=""): @@ -71,24 +46,9 @@ class StrTest( def __str__(self): return self - class Foo9(str8): - def __str__(self): - return "string" - def __unicode__(self): - return "not unicode" - self.assertEqual(str(Foo1()), "foo") - self.assertEqual(str(Foo2()), "foo") - self.assertEqual(str(Foo3()), "foo") - self.assertEqual(str(Foo4("bar")), "foo") - self.assertEqual(str(Foo5("bar")), "foo") - self.assertEqual(str8(Foo6("bar")), "foos") - self.assertEqual(str(Foo6("bar")), "foou") - self.assertEqual(str8(Foo7("bar")), "foos") - self.assertEqual(str(Foo7("bar")), "foou") + self.assertEqual(str(Foo7("bar")), "foos") self.assertEqual(str(Foo8("foo")), "foofoo") - self.assertEqual(str8(Foo9("foo")), "string") - self.assertEqual(str(Foo9("foo")), "not unicode") def test_expandtabs_overflows_gracefully(self): # This test only affects 32-bit platforms because expandtabs can only take |