Commit 64ebc791 authored by Jason Swails's avatar Jason Swails
Browse files

Apparently "from XXX import *" is only allowed at the module level (I get a

SyntaxWarning otherwise). So move those imports back to the module level and
save any error messages for when the tests are actually run (if ever).

python -m simtk.testInstallation

runs the tests, whereas

python -c "import simtk.testInstallation"

does not.
parent 0a86b311
...@@ -7,17 +7,24 @@ class TestingError(Exception): ...@@ -7,17 +7,24 @@ class TestingError(Exception):
""" """
An error is encountered when An error is encountered when
""" """
pass
try:
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
except ImportError as err:
simtk_import_failed = True
simtk_import_error = err.message
else:
simtk_import_failed = False
def run_tests(): def run_tests():
try:
from simtk.openmm.app import * if simtk_import_failed:
from simtk.openmm import *
from simtk.unit import *
except ImportError as err:
raise TestingError('Failed to import OpenMM packages; Make sure OpenMM\n' raise TestingError('Failed to import OpenMM packages; Make sure OpenMM\n'
'is installed and the library path is set correctly.\n' 'is installed and the library path is set correctly.\n'
'Error message: %s' % err.message) 'Error message: %s' % simtk_import_error)
# Create a System for the tests. # Create a System for the tests.
data_dir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), 'openmm', 'app', 'data') data_dir = os.path.join(os.path.abspath(os.path.split(__file__)[0]), 'openmm', 'app', 'data')
pdb = PDBFile(os.path.join(data_dir, 'test.pdb')) pdb = PDBFile(os.path.join(data_dir, 'test.pdb'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment