在3ds Max中使用Pytest测试框架的命令行实用程序
maxpytest的Python项目详细描述
maxpytest
概述
命令行工具,用于在3ds Max中使用Pytest框架的友好测试工作流
- 使用所有3ds Max Python API运行测试,包括gui/pyside2库
- 来自pipenv虚拟环境的源依赖项
- 为每个测试调用自动化新的3ds Max/Python会话
设置
使用pip
安装使用Python2.7与PIP一起安装:
pip install maxpytest
用法
由于python导入系统的缓存机制和pytest的设计,对测试文件(以及它们导入的任何模块)所做的更改不会反映在同一python进程中随后的pytest调用中。这意味着确保反映更改需要重新启动3ds Max/Python会话。
参数-m/--max
指导maxpytest
如何运行测试。要使maxpytest自动处理关闭和重新启动3ds Max,run your tests using MXSPyCOM。对于简单的设置,或者针对多个3ds Max版本,run your tests directly with 3ds Max。要使用第一个发现的方法,run your tests using the default run method。
包括来自pipenv虚拟环境的站点包
如果当前工作目录是安装了pipenv虚拟环境的项目根目录,则运行测试的3ds Max Python环境可以使用该环境的站点包。使用--cwd
重写当前工作目录会相应地影响此行为。
如果在当前工作目录中没有发现pipenv虚拟环境,并且虚拟环境包含pytest包,则使用该pytest包运行测试。否则将使用maxpytest的pytest依赖项。
要安装pipenv,请从项目根目录运行:
pip install pipenv
然后,设置pipenv虚拟环境:
pipenv --python 2.7 install
将pytest添加到虚拟环境:
pipenv install pytest
使用mxspycom
运行测试使用MXSPyCOM运行测试时,将自动处理关闭和重新启动3ds Max。任何未保存的工作将在关闭前触发保存提示。有关MXSPyCOM的更多信息,请参见wiki。
要调用测试,请使用maxpytest -m [path to MXSPyCOM.exe] -py [pytest args]
,并将pytest参数放在-py
或--pytest
之后作为最后的命令参数。
例如:
# 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/
将测试结果打印到3ds Max侦听器。
使用3ds Max直接运行测试
若要在3ds Max中运行测试而不使用MXSPYCOM,请将-m/--max
与要作为目标的3ds Max的版本年份一起使用,或使用3dsmax.exe的完整路径。
例如:
# 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
测试结果将打印到3ds Max侦听器。
使用默认的run方法运行测试
如果使用maxtest
时没有-m/--max
参数,maxpytest将在C:\Program Files\MXSPyCOM\MXSPyCOM.exe
处搜索mxspycom.exe。如果找不到,将使用系统上安装的最新版本的3ds Max。
联系人
对于问题、支持或功能请求,请打开问题或通过mail@garytyler.com联系。