[12] | 1 | # Copyright David Abrahams 2004. Distributed under the Boost |
---|
| 2 | # Software License, Version 1.0. (See accompanying |
---|
| 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
| 4 | """ |
---|
| 5 | >>> from tuple_ext import * |
---|
| 6 | >>> def printer(*args): |
---|
| 7 | ... for x in args: print x, |
---|
| 8 | ... print |
---|
| 9 | ... |
---|
| 10 | >>> print convert_to_tuple("this is a test string") |
---|
| 11 | ('t', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g') |
---|
| 12 | >>> t1 = convert_to_tuple("this is") |
---|
| 13 | >>> t2 = (1,2,3,4) |
---|
| 14 | >>> test_operators(t1,t2,printer) |
---|
| 15 | ('t', 'h', 'i', 's', ' ', 'i', 's', 1, 2, 3, 4) |
---|
| 16 | >>> make_tuple() |
---|
| 17 | () |
---|
| 18 | >>> make_tuple(42) |
---|
| 19 | (42,) |
---|
| 20 | >>> make_tuple('hello', 42) |
---|
| 21 | ('hello', 42) |
---|
| 22 | """ |
---|
| 23 | |
---|
| 24 | def run(args = None): |
---|
| 25 | import sys |
---|
| 26 | import doctest |
---|
| 27 | |
---|
| 28 | if args is not None: |
---|
| 29 | sys.argv = args |
---|
| 30 | return doctest.testmod(sys.modules.get(__name__)) |
---|
| 31 | |
---|
| 32 | if __name__ == '__main__': |
---|
| 33 | print "running..." |
---|
| 34 | import sys |
---|
| 35 | status = run()[0] |
---|
| 36 | if (status == 0): print "Done." |
---|
| 37 | sys.exit(status) |
---|