def order_dict( d): res = dictOrder() for k,v in d.iteritems(): if isinstance( v, dict): res[k] = order_dict( v) else: res[k] = v return res
def gen_classes_schema( classes_unordered): classes = order_dict( classes_unordered) inh_sets = [ inh[ 0] for inh in classes.values()] #i.e. [ 'concrete joined single', 'joined concrete'] base_sets = [ inh[ 1] for inh in classes.values()] #i.e. [ 'Base A', 'B'] for bases in get_combs( base_sets): reduced_inh_sets = list( inh_sets) for i in range( len( bases)): if bases[ i] == 'Base': reduced_inh_sets[ i] = 'concrete' #dont cycle inhs for Base for inhs in get_combs( reduced_inh_sets): assert len(inhs) == len( bases) schema = dictOrder() for klas, inh_data in classes.iteritems(): i = classes.keys().index( klas) schema[ klas] = [ inhs[ i], bases[ i]] yield schema
P( test_B_inh_A_ref, func_params= dict( inh=CONCRETE, refs= dict(B='A'))), P( test_B_inh_A_ref, func_params= dict( inh=CONCRETE, refs= dict(B='B'))), P( test_B_inh_A_ref, func_params= dict( inh=JOINED, refs= dict(A='A'))), P( test_B_inh_A_ref, func_params= dict( inh=JOINED, refs= dict(A='B'))), P( test_B_inh_A_ref, func_params= dict( inh=JOINED, refs= dict(B='A'))), P( test_B_inh_A_ref, func_params= dict( inh=JOINED, refs= dict(B='B'))), # P( test_B_inh_A_ref, func_params= dict( inh=JOINED, refs= dict(B='B')), ] #all_cases = [] for inh in gen_inh_types( [CONCRETE, JOINED], 2): if inh[0] == CONCRETE and inh[1] == CONCRETE: print 'concrete polymorphism not supported, ignoring user_defined A/B/C concrete' continue klasi = dictOrder( ( ('A', [CONCRETE, 'Base']), ('B', [inh[0], 'A']), ('C', [inh[1], 'B']) ) ) case = P( test_user_defined, func_params= dict( klasi= klasi, refs= dict( A='B', B='A', C='A'), ) ) all_cases.append( case) zall_cases = [ P( test_inh_nonempty, func_params= dict( inh=JOINED), ), ] from tests.util import case2unittest, tester class MapperCase( case2unittest.Case):