def run_tests_from_commandline():
"""Runs the tests in Maya standalone mode.
This is called when running cmt/bin/runmayatests.py from the commandline.
"""
import maya.standalone
maya.standalone.initialize()
# Make sure all paths in PYTHONPATH are also in sys.path
# When a maya module is loaded, the scripts folder is added to PYTHONPATH, but it doesn't seem
# to be added to sys.path. So we are unable to import any of the python files that are in the
# module/scripts folder. To workaround this, we simply add the paths to sys ourselves.
realsyspath = [os.path.realpath(p) for p in sys.path]
pythonpath = os.environ.get('PYTHONPATH', '')
for p in pythonpath.split(os.pathsep):
p = os.path.realpath(p) # Make sure symbolic links are resolved
if p not in realsyspath:
sys.path.insert(0, p)
run_tests()
# Starting Maya 2016, we have to call uninitialize
if float(cmds.about(v=True)) >= 2016.0:
maya.standalone.uninitialize()
评论列表
文章目录