Skip to main content

Command line utility for using the Pytest testing framework in 3ds Max

Project description

maxpytest

PyPI version Build status codecov Code style: black

Overview

Command line tool for a friendly testing workflow using the Pytest framework in 3ds Max

  • Run tests with all 3ds Max Python APIs, including GUI/PySide2 libraries
  • Source dependencies from a pipenv virtual environment
  • Automate a new 3ds Max/python session for each tests invocation

Setup

Install with pip

Install with pip using Python 2.7:

pip install maxpytest

Usage

Due 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 invocations in the same python process. This means ensuring that your changes are reflected requires a restart of the 3ds Max/python session.

The argument -m/--max directs maxpytest how 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 environment

If the current working directory is a project root with an installed pipenv virtual environment, that environment's site-packages are made available to the 3ds Max python environment running the tests. Overriding the current working directory with --cwd effects this behavior accordingly.

If no pipenv virtual 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 pipenv

Then, setup a pipenv virtual environment:

pipenv --python 2.7 install

Add pytest to the virtual environment:

pipenv install pytest

Run your tests using MXSPyCOM

When you run your tests with MXSPyCOM, the closing and relaunching 3ds Max is handled automatically. Any unsaved work will trigger a prompt to save it before closing. For more about MXSPyCOM see the wiki.

To invoke your tests, use maxpytest -m [path to MXSPyCOM.exe] -py [pytest args], with Pytest args following -py or --pytest as 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 Max

To run tests in 3ds max without using MXSPyCOM, use -m/--max with 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/ -v

Test results will print to the 3ds Max Listener.

Run your tests using the default run method

If maxtest is used without a -m/--max argument, maxpytest will search for MXSPyCOM.exe at C:\Program Files\MXSPyCOM\MXSPyCOM.exe. If not found, the most recent version of 3ds Max installed on the system will be used.

Contact

For questions, support, or feature requests, please open an issue or reach out at mail@garytyler.com .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maxpytest-1.0.3.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file maxpytest-1.0.3.tar.gz.

File metadata

  • Download URL: maxpytest-1.0.3.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for maxpytest-1.0.3.tar.gz
Algorithm Hash digest
SHA256 4923a799c09c327c00047fa27fe125dd7b57f0859afef57fcd582aaa7fcaf877
MD5 1ac0732b1c124581bd177b9f58521a1d
BLAKE2b-256 7997025c4ef4824bb6dbf187cfb004a22e55296d8984a6404690715df9e0cb50

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page