Package: maxpytest
maxpytestOverviewCommand line tool for a friendly testing workflow using thePytestframework in 3ds MaxRun tests with all 3ds Max Python APIs, including GUI/PySide2 librariesSource dependencies from apipenvvirtual environmentAutomate a new 3ds Max/python session for each tests invocationSetupInstall with pipInstall with pip using Python 2.7:pip install maxpytestUsageDue to the caching mechanism of python's import system and Pytest's design, changes made to test files (and any modules they import) will not be reflected in subsequent Pytest invocationsin the same python process. This means ensuring that your changes are reflected requires a restart of the 3ds Max/python session.The argument-m/--maxdirectsmaxpytesthow to run your tests. For maxpytest to handle closing and relaunching 3ds Max automatically,run your tests using MXSPyCOM. For a simple setup, or if targeting multiple 3ds Max versions,run your tests directly with 3ds Max. To use the first discovered method,run your tests using the default run method.Including site-packages from a pipenv virtual environmentIf the current working directory is a project root with an installedpipenvvirtual environment, that environment's site-packages are made available to the 3ds Max python environment running the tests. Overriding the current working directory with--cwdeffects this behavior accordingly.If nopipenvvirtual environment is discovered in the current working directory and the virtual environment includes a pytest package, that pytest package is used to run the tests. Otherwise maxpytest's pytest dependency is used.To install pipenv, run from your project root:pip install pipenvThen, setup a pipenv virtual environment:pipenv --python 2.7 installAdd pytest to the virtual environment:pipenv install pytestRun your tests using MXSPyCOMWhen you run your tests withMXSPyCOM, the closing and relaunching 3ds Max is handled automatically. Any unsaved work will trigger a prompt to save it before closing. For more aboutMXSPyCOMsee thewiki.To invoke your tests, usemaxpytest -m [path to MXSPyCOM.exe] -py [pytest args], with Pytest args following-pyor--pytestas the final command argument.For example:# Relaunch 3ds Max then invoke pytest from current working dir with verbose
maxpytest -m "C:\\Program Files\\MXSPyCOM\\MXSPyCOM.exe" -py -v .

# Relaunch 3ds Max then invoke pytest in directory ./tests
maxpytest -m "C:\\Program Files\\MXSPyCOM\\MXSPyCOM.exe" -py tests/

# Skip relaunch and just invoke pytest in directory ./tests
maxpytest -m "C:\\Program Files\\MXSPyCOM\\MXSPyCOM.exe" --no-restart -py tests/Test results print to the 3ds Max Listener.Run your tests directly with 3ds MaxTo run tests in 3ds max without using MXSPyCOM, use-m/--maxwith the version year of the 3ds Max you wish to target, or a full path to 3dsmax.exe.For example:# Invoke pytest from current working dir in a new instance of 3ds Max 2019
maxpytest -m "C:\\Program Files\\Autodesk\\3ds Max 2019\\3dsmax.exe"

# Invoke pytest from current working dir in a new instance of 3ds Max 2019
maxpytest -m 2019

# Invoke pytest from tests/ in a new instance of 3dsMax 2016
maxpytest -m 2016 -py tests/ -vTest results will print to the 3ds Max Listener.Run your tests using the default run methodIfmaxtestis used without a-m/--maxargument, maxpytest will search for MXSPyCOM.exe atC:\Program Files\MXSPyCOM\MXSPyCOM.exe. If not found, the most recent version of 3ds Max installed on the system will be used.ContactFor questions, support, or feature requests, please open an issue or reach out atmail@garytyler.com.