Skip to content

Commit 6c19edc

Browse files
committed
bump version, add custom path to tests
1 parent 1ec88d4 commit 6c19edc

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

PyTMM/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"""
44

55
__author__ = "Pavel Dmitriev"
6-
__version__ = "1.0.1c"
6+
__version__ = "1.0.2"
77
__license__ = "GPLv3"

PyTMM/tests/test_refractiveIndex.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,40 @@
2323

2424

2525
class 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

Comments
 (0)