2323
2424
2525class TestRefractiveIndex (TestCase ):
26+
2627 def test_defaultInit (self ):
27- database = RefractiveIndex ()
28- assert os .path .exists (database .referencePath )
29- assert os .path .exists (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
30- assert os .path .isfile (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
28+
29+ try :
30+ database = RefractiveIndex ()
31+ except FileNotFoundError :
32+ print ("database not found at default location, checking custom location from \' ./refractiveindex_database_location.txt\' " )
33+ database_path = ""
34+ with open ("refractiveindex_database_location.txt" , "r" ) as f :
35+ database_path = f .readline ()
36+
37+ database = RefractiveIndex (databasePath = database_path )
38+ else :
39+ assert os .path .exists (database .referencePath )
40+ assert os .path .exists (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
41+ assert os .path .isfile (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
42+
43+ finally :
44+ assert os .path .exists (database .referencePath )
45+ assert os .path .exists (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
46+ assert os .path .isfile (os .path .join (database .referencePath , os .path .normpath ("library.yml" )))
47+
3148
3249 def test_getMaterialFilename (self ):
33- database = RefractiveIndex ()
50+ try :
51+ database = RefractiveIndex ()
52+ except FileNotFoundError :
53+ print ("database not found at default location, checking custom location from \' ./refractiveindex_database_location.txt\' " )
54+ database_path = ""
55+ with open ("refractiveindex_database_location.txt" , "r" ) as f :
56+ database_path = f .readline ()
57+
58+ database = RefractiveIndex (databasePath = database_path )
59+
3460 for sh in database .catalog :
3561 for b in sh ['content' ]:
3662 if 'DIVIDER' not in b :
@@ -41,7 +67,16 @@ def test_getMaterialFilename(self):
4167 assert os .path .isfile (os .path .normpath (mat ))
4268
4369 def test_getMaterial (self ):
44- database = RefractiveIndex ()
70+ try :
71+ database = RefractiveIndex ()
72+ except FileNotFoundError :
73+ print ("database not found at default location, checking custom location from \' ./refractiveindex_database_location.txt\' " )
74+ database_path = ""
75+ with open ("refractiveindex_database_location.txt" , "r" ) as f :
76+ database_path = f .readline ()
77+
78+ database = RefractiveIndex (databasePath = database_path )
79+
4580 for sh in database .catalog :
4681 for b in sh ['content' ]:
4782 if 'DIVIDER' not in b :
0 commit comments