annotate Lib/test/test_buffer.py @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents b36cb4602e21
children 6b3217b96a77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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():
59783
c8c840162804 #7092 - Silence more py3k deprecation warnings, using test_support.check_py3k_warnings() helper.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 58198
diff changeset
26 with test_support.check_py3k_warnings(("buffer.. not supported",
63572
51102abdec50 Merged revisions 79165 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 42951
diff changeset
27 DeprecationWarning)):
51102abdec50 Merged revisions 79165 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 42951
diff changeset
28 test_support.run_unittest(BufferTests)
42951
9620134010a5 Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff changeset
29
9620134010a5 Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff changeset
30 if __name__ == "__main__":
9620134010a5 Improve extended slicing support in builtin types and classes. Specifically:
Thomas Wouters <thomas@python.org>
parents:
diff changeset
31 test_main()