Skip to content

Commit

Permalink
Update test_import.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aradhakrishnanGFDL authored Jul 19, 2024
1 parent f13771b commit dfa4629
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit dfa4629

Please sign in to comment.