From dfa46297b9e81fa22e3df66690cc2346d09b00e5 Mon Sep 17 00:00:00 2001 From: Aparna Radhakrishnan Date: Fri, 19 Jul 2024 15:36:20 -0400 Subject: [PATCH] Update test_import.py --- tests/test_import.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/test_import.py b/tests/test_import.py index 3869836..9b658ec 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -1,24 +1,17 @@ +import os,sys def check_import(): try: from intakebuilder import gfdlcrawler, CSVwriter, configparser - print("Imported intakebuilder, gfdlcrawler, CSVwriter, configparser") - return True - except ModuleNotFoundError: + except ImportError: print("The module intakebuilder is not installed. Do you have intakebuilder in your sys.path or have you activated the conda environment with the intakebuilder package in it? ") print("Attempting again with adjusted sys.path ") try: - sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+"/catalogbuilder") + from intakebuilder import gfdlcrawler, CSVwriter, builderconfig, configparser except: print("Unable to adjust sys.path") - #print(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - try: - from intakebuilder import gfdlcrawler, CSVwriter, builderconfig, configparser - print("Imported, and relied on sys.path") - return True - except ModuleNotFoundError: - print("The module 'intakebuilder' is still not installed. Do you have intakebuilder in your sys.path or have you activated the conda environment with the intakebuilder package in it? ") - raise ImportError('Error importing intakebuilder and other packages') - return -97 + raise ImportError('Error importing intakebuilder and other packages') + return -97 def test_import(): assert check_import() == True