# this program creates a list of possible combinations and creates a string # that represents the function name. This way I get all the possibilties # and don't forget any src = ['src_file','src_directory_empty', 'src_directory_not_empty', \ 'src_file_or_directory_not_exist'] dst = ['dst_file_exist','dst_not_exist','dst_directory_empty', \ 'dst_directory_not_empty'] print "Make sure you have functions in test_os for all of these" for index_src in range(0, len(src)): for index_dst in range(0, len(dst)): function_name = "test_rename_" + src[index_src] + "_" + \ dst[index_dst] print function_name for index_src in range(0, len(src)): for index_dst in range(0, len(dst)): function_name = src[index_src] + ":" + dst[index_dst] print function_name result_unix = dict(a='value',another='value',) result_windows = dict(a='value',another='value',) result_unix['src_file:dst_file_exist'] = "rename overwrite" result_windows['src_file:dst_file_exist'] = "raises OSError" result_unix['src_file:dst_not_exist'] = "rename" result_windows['src_file:dst_not_exist'] = "rename" result_unix['src_file:dst_directory_empty'] = "raises OSError" result_windows['src_file:dst_directory_empty'] = "raises OSError" result_unix['src_file:dst_directory_not_empty'] = "raises OSError" result_windows['src_file:dst_directory_not_empty'] = "raises OSError" result_unix['src_directory_empty:dst_file_exist'] = "raises OSError" result_windows['src_directory_empty:dst_file_exist'] = "raises OSError" result_unix['src_directory_empty:dst_not_exist'] = "rename" result_windows['src_directory_empty:dst_not_exist'] = "rename" result_unix['src_directory_empty:dst_directory_empty'] = "rename overwrite" result_windows['src_directory_empty:dst_directory_empty'] = "raises FileExistsError" result_unix['src_directory_empty:dst_directory_not_empty'] = "raises OSError" result_windows['src_directory_empty:dst_directory_not_empty'] = "raises OSError" result_unix['src_directory_not_empty:dst_file_exist'] = "raises OSError" result_windows['src_directory_not_empty:dst_file_exist'] = "raises OSError" result_unix['src_directory_not_empty:dst_not_exist'] = "rename" result_windows['src_directory_not_empty:dst_not_exist'] = "rename" result_unix['src_directory_not_empty:dst_directory_empty'] = "rename overwrite" result_windows['src_directory_not_empty:dst_directory_empty'] = "raises FileExistsError" result_unix['src_directory_not_empty:dst_directory_not_empty'] = "raises OSError" result_windows['src_directory_not_empty:dst_directory_not_empty'] = "raises OSError" result_unix['src_file_or_directory_not_exist:dst_file_exist'] = "raises OSError" result_windows['src_file_or_directory_not_exist:dst_file_exist'] = "raises OSError" result_unix['src_file_or_directory_not_exist:dst_not_exist'] = "raises OSError" result_windows['src_file_or_directory_not_exist:dst_not_exist'] = "raises OSError" result_unix['src_file_or_directory_not_exist:dst_directory_empty'] = "raises OSError" result_windows['src_file_or_directory_not_exist:dst_directory_empty'] = "raises OSError" result_unix['src_file_or_directory_not_exist:dst_directory_not_empty'] = "raises OSError" result_windows['src_file_or_directory_not_exist:dst_directory_not_empty'] = "raises OSError" # now lets pretty print a nice table print "For Unix" space_per_cell = 30 # print the header first for index_src in range(0, 15): print " ", for index_src in range(0, len(src)): print src[index_src].ljust(space_per_cell), print "" for index_dst in range(0, len(dst)): print dst[index_dst].ljust(space_per_cell), for index_src in range(0, len(src)): key = src[index_src] + ":" + dst[index_dst] print result_unix[key].ljust(space_per_cell), print "" print "For Windows" space_per_cell = 30 # print the header first for index_src in range(0, 15): print " ", for index_src in range(0, len(src)): print src[index_src].ljust(space_per_cell), print "" for index_dst in range(0, len(dst)): print dst[index_dst].ljust(space_per_cell), for index_src in range(0, len(src)): key = src[index_src] + ":" + dst[index_dst] print result_windows[key].ljust(space_per_cell), print ""