def grouped_by_prefix(args, prefixes):
 group_args = []
 current_scope = None
 for arg in args.strip().split():
  assert (not arg.startswith('-')), 'REQUIRE: arg, not options'
  scope = select_prefix_for(arg, prefixes)
  if (scope != current_scope):
   if group_args:
    (yield ' '.join(group_args))
    group_args = []
   current_scope = scope
  group_args.append(arg)
 if group_args:
  (yield ' '.join(group_args))

def grouped_by_prefix ( args , prefixes ) : group_args = [ ] current_scope = None for arg in args . strip ( ) . split ( ) : assert ( not arg . startswith ( '-' ) ) , 'REQUIRE: arg, not options' scope = select_prefix_for ( arg , prefixes ) if ( scope != current_scope ) : if group_args : ( yield ' ' . join ( group_args ) ) group_args = [ ] current_scope = scope group_args . append ( arg ) if group_args : ( yield ' ' . join ( group_args ) )
group behave args by scope into multiple test-runs .