]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
strings vs bytes, bytes wins again
authorGregory P. Smith <greg@mad-scientist.com>
Wed, 29 Aug 2007 05:06:13 +0000 (05:06 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Wed, 29 Aug 2007 05:06:13 +0000 (05:06 +0000)
Lib/bsddb/test/test_compare.py

index d49aab7eb2ad2cd338b793229e57526891464958..0a575906c0f296bc128f4c6ef646c97e415e1e00 100644 (file)
@@ -26,9 +26,9 @@ def make_reverse_comparator (cmp):
         return - delegate (left, right)
     return reverse
 
-_expected_lexical_test_data = [bytes(_) for _ in
+_expected_lexical_test_data = [s.encode('ascii') for s in
         ('', 'CCCP', 'a', 'aaa', 'b', 'c', 'cccce', 'ccccf')]
-_expected_lowercase_test_data = [bytes(_) for _ in
+_expected_lowercase_test_data = [s.encode('ascii') for s in
         ('', 'a', 'aaa', 'b', 'c', 'CC', 'cccce', 'ccccf', 'CCCP')]
 
 class ComparatorTests (unittest.TestCase):
@@ -73,7 +73,7 @@ class AbstractBtreeKeyCompareTestCase (unittest.TestCase):
     def addDataToDB (self, data):
         i = 0
         for item in data:
-            self.db.put (item, str (i))
+            self.db.put (item, str(i).encode("ascii"))
             i = i + 1
 
     def createDB (self, key_comparator):
@@ -181,7 +181,7 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
             sys.stderr = stdErr
             errorOut = temp.getvalue()
             if not successRe.search(errorOut):
-                self.fail("unexpected stderr output:\n"+errorOut)
+                self.fail("unexpected stderr output: %r" % errorOut)
 
     def _test_compare_function_exception (self):
         self.startTest ()