PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/Lib/test/test_buffer.py

http://unladen-swallow.googlecode.com/
Python | 29 lines | 20 code | 3 blank | 6 comment | 0 complexity | 9ffe3bc42536b5a1d8f02f68699b163e MD5 | raw file
 1"""Unit tests for buffer objects.
 2
 3For now, tests just new or changed functionality.
 4
 5"""
 6
 7import unittest
 8from test import test_support
 9
10class BufferTests(unittest.TestCase):
11
12    def test_extended_getslice(self):
13        # Test extended slicing by comparing with list slicing.
14        s = "".join(chr(c) for c in list(range(255, -1, -1)))
15        b = buffer(s)
16        indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
17        for start in indices:
18            for stop in indices:
19                # Skip step 0 (invalid)
20                for step in indices[1:]:
21                    self.assertEqual(b[start:stop:step],
22                                     s[start:stop:step])
23
24
25def test_main():
26    test_support.run_unittest(BufferTests)
27
28if __name__ == "__main__":
29    test_main()