#NEWLINE# def test_source_generator( self ) : #NEWLINE# #INDENT# '\n        TODO: test inflating independently (string, file list, dict) and recursive inflating\n        for all.\n        ' #NEWLINE# class SourceGeneratorMock ( SourceGenerator ) : #NEWLINE# #INDENT# def __init__( self , source_list ) : #NEWLINE# #INDENT# super ( SourceGeneratorMock , self ) . __init__ ( source_list ) #NEWLINE# #UNINDENT# @ classmethod #NEWLINE# def do_glob( cls , source ) : #NEWLINE# #INDENT# '\n                "Normal" do_glob fails if file or description does not exist. \n                ' #NEWLINE# if ( len ( glob . glob ( source ) ) == 0 ) : #NEWLINE# #INDENT# return [ source ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return glob . glob ( source ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# sources_list = [ 'file.lel' , os . path . join ( test_data . __path__ [ 0 ] , 'lots_of_files.lst' ) , { #NEWLINE# #INDENT# 'source' : 'protein.pdb' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'source' : 'another_protein.pdb' , #NEWLINE# 'with_kw' : 'KW!' , #NEWLINE# #UNINDENT# } , os . path . join ( test_data . __path__ [ 0 ] , 'bunch_of_files.lst' ) , { #NEWLINE# #INDENT# 'source' : os . path . join ( test_data . __path__ [ 0 ] , '*.pdb' ) , #NEWLINE# 'selection' : 'all' , #NEWLINE# #UNINDENT# } ] #NEWLINE# expected_ordered_sources = [ 'file.lel' , 'one.txt' , { #NEWLINE# #INDENT# 'source' : 'two.txt' , #NEWLINE# 'lol' : 'lol' , #NEWLINE# #UNINDENT# } , 'three.ff' , { #NEWLINE# #INDENT# 'source' : 'protein.pdb' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'source' : 'another_protein.pdb' , #NEWLINE# 'with_kw' : 'KW!' , #NEWLINE# #UNINDENT# } , 'four.txt' , 'six.txt' , 'seven.txt' , { #NEWLINE# #INDENT# 'source' : 'pdb3.pdb' , #NEWLINE# 'selection' : 'all' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'source' : 'pdb2.pdb' , #NEWLINE# 'selection' : 'all' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'source' : 'pdb1.pdb' , #NEWLINE# 'selection' : 'all' , #NEWLINE# #UNINDENT# } ] #NEWLINE# sources = SourceGeneratorMock . inflate_source_list ( expected_ordered_sources ) #NEWLINE# def normalize_sources( sources ) : #NEWLINE# #INDENT# norm_sources = [ ] #NEWLINE# for s in norm_sources : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# s = s [ 'source' ] #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# s = s #NEWLINE# #UNINDENT# norm_sources . append ( os . path . basename ( s ) ) #NEWLINE# #UNINDENT# return norm_sources #NEWLINE# #UNINDENT# self . assertItemsEqual ( normalize_sources ( expected_ordered_sources ) , normalize_sources ( sources ) )