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 ef86c6d commit 78897ff
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
def check_import():
try:
from intakebuilder import getinfo, localcrawler, CSVwriter
print("Imported intakebuilder and getinfo, localcrawler, CSVwriter ")
except ImportError:
raise ImportError('Error importing intakebuilder and other packages')
return -97
return True
from intakebuilder import gfdlcrawler, CSVwriter, configparser
print("Imported intakebuilder, gfdlcrawler, CSVwriter, configparser")
return True
except ModuleNotFoundError:
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__))))
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:
sys.exit("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

def test_import():
assert check_import() == True


0 comments on commit 78897ff

Please sign in to comment.