Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_buffer.py @ 49258:25f809123df6 legacy-trunk
Issue #3925: Ignores shutil.rmtree error on cygwin too.
Reviewed by Benjamin Peterson.
| author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> |
|---|---|
| date | Sun, 21 Sep 2008 20:48:41 +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() |
