From 6c19edc5799cd36f1ace123018c0a23ce4450f14 Mon Sep 17 00:00:00 2001 From: Pavel Dmitriev Date: Sun, 17 Feb 2019 17:09:24 +0800 Subject: [PATCH] bump version, add custom path to tests --- PyTMM/__init__.py | 2 +- PyTMM/tests/test_refractiveIndex.py | 47 +++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/PyTMM/__init__.py b/PyTMM/__init__.py index 39f48df..65589c9 100644 --- a/PyTMM/__init__.py +++ b/PyTMM/__init__.py @@ -3,5 +3,5 @@ """ __author__ = "Pavel Dmitriev" -__version__ = "1.0.1c" +__version__ = "1.0.2" __license__ = "GPLv3" diff --git a/PyTMM/tests/test_refractiveIndex.py b/PyTMM/tests/test_refractiveIndex.py index 816e29e..041c9d1 100644 --- a/PyTMM/tests/test_refractiveIndex.py +++ b/PyTMM/tests/test_refractiveIndex.py @@ -23,14 +23,40 @@ class TestRefractiveIndex(TestCase): + def test_defaultInit(self): - database = RefractiveIndex() - assert os.path.exists(database.referencePath) - assert os.path.exists(os.path.join(database.referencePath, os.path.normpath("library.yml"))) - assert os.path.isfile(os.path.join(database.referencePath, os.path.normpath("library.yml"))) + + try: + database = RefractiveIndex() + except FileNotFoundError: + print("database not found at default location, checking custom location from \'./refractiveindex_database_location.txt\'") + database_path = "" + with open("refractiveindex_database_location.txt", "r") as f: + database_path = f.readline() + + database = RefractiveIndex(databasePath=database_path) + else: + assert os.path.exists(database.referencePath) + assert os.path.exists(os.path.join(database.referencePath, os.path.normpath("library.yml"))) + assert os.path.isfile(os.path.join(database.referencePath, os.path.normpath("library.yml"))) + + finally: + assert os.path.exists(database.referencePath) + assert os.path.exists(os.path.join(database.referencePath, os.path.normpath("library.yml"))) + assert os.path.isfile(os.path.join(database.referencePath, os.path.normpath("library.yml"))) + def test_getMaterialFilename(self): - database = RefractiveIndex() + try: + database = RefractiveIndex() + except FileNotFoundError: + print("database not found at default location, checking custom location from \'./refractiveindex_database_location.txt\'") + database_path = "" + with open("refractiveindex_database_location.txt", "r") as f: + database_path = f.readline() + + database = RefractiveIndex(databasePath=database_path) + for sh in database.catalog: for b in sh['content']: if 'DIVIDER' not in b: @@ -41,7 +67,16 @@ def test_getMaterialFilename(self): assert os.path.isfile(os.path.normpath(mat)) def test_getMaterial(self): - database = RefractiveIndex() + try: + database = RefractiveIndex() + except FileNotFoundError: + print("database not found at default location, checking custom location from \'./refractiveindex_database_location.txt\'") + database_path = "" + with open("refractiveindex_database_location.txt", "r") as f: + database_path = f.readline() + + database = RefractiveIndex(databasePath=database_path) + for sh in database.catalog: for b in sh['content']: if 'DIVIDER' not in b: