diff options
author | Fred Drake <fdrake@acm.org> | 2002-05-02 05:27:28 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-05-02 05:27:28 +0000 |
commit | 6e94351ab6aa0a8f6e50b0660ea23bcf5c4333a4 (patch) | |
tree | 99101777085a8ced62325dea4a0f213b44007b5c | |
parent | 79f6c0125a90ce9e9529e74e0cb0426147506c66 (diff) | |
download | cpython-6e94351ab6aa0a8f6e50b0660ea23bcf5c4333a4.tar.gz |
Backport buffer() tests from trunk to avoid regression failures.
-rw-r--r-- | Lib/test/output/test_types | 1 | ||||
-rw-r--r-- | Lib/test/test_types.py | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/output/test_types b/Lib/test/output/test_types index 065594d6a8..46832bf40f 100644 --- a/Lib/test/output/test_types +++ b/Lib/test/output/test_types @@ -13,3 +13,4 @@ test_types 6.5.3 Lists 6.5.3a Additional list operations 6.6 Mappings == Dictionaries +6.7 Buffers diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index bf356872af..0914194d14 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -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" |