Running the tests
To run the tests outside of Maya in a standard Python Interpreter, invoke pytest the standard way in the project folder:
pytest tests
maya_only
marker is defined in tests/__init__.py
:
import os
import pytest
def has_maya():
# type: () -> bool
try:
import maya.cmds as cmds
return True
except ImportError:
pass
return False
maya_only = pytest.mark.skipif(not has_maya(), reason="requires Maya")
skip_if_maya = pytest.mark.skipif(has_maya(), reason="can not run in Maya")
We detect if we are running in Maya by checking if we can import maya.cmds
.
Tests that require Maya are marked with @maya_only
and skipped by pytest if Maya is not available.
For a detailed explanation on executing tests in DCCs, see section Execute Tests in DCCs.
To run the tests in Maya, execute the wrapper script run_tests.py
in mayapy.
The Batch file wrapper run_tests_maya.bat
takes care of adding the dependencies to the PYTHONPATH and calling mayapy with the wrapper script.
run_tests_maya.bat
Last modified August 19, 2020