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 slice_ext import * 6>>> accept_slice(slice(1, None, (1,2))) 71 8>>> try: 9... accept_slice(list((1,2))) 10... print("test failed") 11... except: 12... print("test passed") 13... 14test passed 15>>> import sys 16>>> if sys.version_info[0] == 2 and sys.version_info[1] >= 3: 17... check_string_rich_slice() 18... elif sys.version_info[0] > 2: 19... check_string_rich_slice() 20... else: 21... print(1) 22... 231 24>>> check_slice_get_indices( slice(None)) 250 26>>> check_slice_get_indices( slice(2,-2)) 270 28>>> check_slice_get_indices( slice(2, None, 2)) 295 30>>> check_slice_get_indices( slice(2, None, -1)) 31-12 32>>> check_slice_get_indices( slice( 20, None)) 330 34>>> check_slice_get_indices( slice( -2, -5, -2)) 356 36""" 37 38# Performs an affirmative and negative argument resolution check. 39# checks the operation of extended slicing in new strings (Python 2.3 only). 40 41def run(args = None): 42 import sys 43 import doctest 44 45 if args is not None: 46 sys.argv = args 47 return doctest.testmod(sys.modules.get(__name__)) 48 49if __name__ == '__main__': 50 print("running...") 51 import sys 52 status = run()[0] 53 if (status == 0): print("Done.") 54 sys.exit(status) 55