• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)
4from __future__ import print_function
5"""
6>>> from dict_ext import *
7>>> def printer(*args):
8...     for x in args: print(x, end='')
9...     print('')
10...
11>>> print(new_dict())
12{}
13>>> print(data_dict())
14{1: {'key2': 'value2'}, 'key1': 'value1'}
15>>> tmp = data_dict()
16>>> print(dict_keys(tmp))
17[1, 'key1']
18>>> print(dict_values(tmp))
19[{'key2': 'value2'}, 'value1']
20>>> print(dict_items(tmp))
21[(1, {'key2': 'value2'}), ('key1', 'value1')]
22>>> print(dict_from_sequence([(1,1),(2,2),(3,3)]))
23{1: 1, 2: 2, 3: 3}
24>>> test_templates(printer) #doctest: +NORMALIZE_WHITESPACE
25a test string
2613
27None
28{1.5: 13, 1: 'a test string'}
29default
30default
31"""
32
33def run(args = None):
34    import sys
35    import doctest
36
37    if args is not None:
38        sys.argv = args
39    return doctest.testmod(sys.modules.get(__name__))
40
41if __name__ == '__main__':
42    print("running...")
43    import sys
44    status = run()[0]
45    if (status == 0): print("Done.")
46    sys.exit(status)
47