#NEWLINE# def pytest_collection_modifyitems( session , config , items ) : #NEWLINE# #INDENT# rebuilt_items = collections . defaultdict ( list ) #NEWLINE# items [ : ] = [ item for item in items if ( isinstance ( item . parent , pytest . Instance ) and ( not item . parent . parent . name . startswith ( '_' ) ) ) ] #NEWLINE# test_classes = set ( ( item . parent for item in items ) ) #NEWLINE# for test_class in test_classes : #NEWLINE# #INDENT# for sub_cls in plugin_base . generate_sub_tests ( test_class . cls , test_class . parent . module ) : #NEWLINE# #INDENT# if ( sub_cls is not test_class . cls ) : #NEWLINE# #INDENT# list_ = rebuilt_items [ test_class . cls ] #NEWLINE# for inst in pytest . Class ( sub_cls . __name__ , parent = test_class . parent . parent ) . collect ( ) : #NEWLINE# #INDENT# list_ . extend ( inst . collect ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# newitems = [ ] #NEWLINE# for item in items : #NEWLINE# #INDENT# if ( item . parent . cls in rebuilt_items ) : #NEWLINE# #INDENT# newitems . extend ( rebuilt_items [ item . parent . cls ] ) #NEWLINE# rebuilt_items [ item . parent . cls ] [ : ] = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# newitems . append ( item ) #NEWLINE# #UNINDENT# #UNINDENT# items [ : ] = sorted ( newitems , key = ( lambda item : ( item . parent . parent . parent . name , item . parent . parent . name , item . name ) ) )