]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport buffer() tests from trunk to avoid regression failures.
authorFred Drake <fdrake@acm.org>
Thu, 2 May 2002 05:27:28 +0000 (05:27 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 2 May 2002 05:27:28 +0000 (05:27 +0000)
Lib/test/output/test_types
Lib/test/test_types.py

index 065594d6a8a66aa715ce762f909a26c79408404c..46832bf40f75aff9794d6afdf59d9e0e70c3e7c1 100644 (file)
@@ -13,3 +13,4 @@ test_types
 6.5.3 Lists
 6.5.3a Additional list operations
 6.6 Mappings == Dictionaries
+6.7 Buffers
index bf356872afc0060a0381a7e4a90a15a175dc0b0a..0914194d149ae2397c71d4097d701628ebb7e0cc 100644 (file)
@@ -289,3 +289,32 @@ for copymode in -1, +1:
                     str(ta), str(tb))
         if a: raise TestFailed, 'a not empty after popitems: %s' % str(a)
         if b: raise TestFailed, 'b not empty after popitems: %s' % str(b)
+
+print '6.7 Buffers'
+try: buffer('asdf', -1)
+except ValueError: pass
+else: raise TestFailed, "buffer('asdf', -1) should raise ValueError"
+
+try: buffer(None)
+except TypeError: pass
+else: raise TestFailed, "buffer(None) should raise TypeError"
+
+a = buffer('asdf')
+hash(a)
+b = a * 5
+if a == b:
+    raise TestFailed, 'buffers should not be equal'
+if str(b) != ('asdf' * 5):
+    raise TestFailed, 'repeated buffer has wrong content'
+if str(a * 0) != '':
+    raise TestFailed, 'repeated buffer zero times has wrong content'
+if str(a + buffer('def')) != 'asdfdef':
+    raise TestFailed, 'concatenation of buffers yields wrong content'
+
+try: a[1] = 'g'
+except TypeError: pass
+else: raise TestFailed, "buffer assignment should raise TypeError"
+
+try: a[0:1] = 'g'
+except TypeError: pass
+else: raise TestFailed, "buffer slice assignment should raise TypeError"