Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_buffer.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | 9620134010a5 |
| children | 51102abdec50 7caf54ce529e |
| rev | line source |
|---|---|
|
42951
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 """Unit tests for buffer objects. |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
3 For now, tests just new or changed functionality. |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
4 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 """ |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 import unittest |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
8 from test import test_support |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
9 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 class BufferTests(unittest.TestCase): |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
11 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
12 def test_extended_getslice(self): |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
13 # Test extended slicing by comparing with list slicing. |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
14 s = "".join(chr(c) for c in list(range(255, -1, -1))) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
15 b = buffer(s) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
16 indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
17 for start in indices: |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
18 for stop in indices: |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
19 # Skip step 0 (invalid) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
20 for step in indices[1:]: |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
21 self.assertEqual(b[start:stop:step], |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
22 s[start:stop:step]) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
23 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
24 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
25 def test_main(): |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
26 test_support.run_unittest(BufferTests) |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
27 |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
28 if __name__ == "__main__": |
|
9620134010a5
Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
29 test_main() |
