本文介绍了在独立的Maya中打开commandPort进行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为脚本编写单元测试,该脚本通过commandPort将python代码发送到Autodesk Maya.该脚本有效;它将代码很好地发送给执行它的Maya.但是出于测试目的,我想编写一个单元测试,在其setUp()中打开一个带有commandPort的独立(命令行)Maya,可以将命令发送至该Maya,然后在tearDown()中再次关闭,这样我就不必每当我处理脚本时,都要保持真实的Maya应用程序处于打开状态.

I am writing unit tests for a script that sends python code to Autodesk Maya trough the commandPort. The script works; it sends code fine to Maya which executes it. For testing purposes however, I want to write a unit test that in its setUp() opens a standalone (commandline) Maya with a commandPort which I can send commands to and then close again in tearDown(), so that I don't have to keep the real Maya application open whenever I work on the scripts.

我该怎么做?

推荐答案

您不能独立运行commandPort,它依赖于GUI循环.但是,您可以运行使独立监听套接字的脚本,也可以运行诸如zeromq或RPyC之类的远程处理程序包. 此链接包括一些有关如何设置和提示的提示在github要点上,它具有一个简单的基于HTML的RPC服务器,该服务器可以独立运行.

You can't run commandPort in a standalone, it relies on the GUI loop. You can, however, run a script which makes the standalone listen on a socket, or us a remoting package like zeromq or RPyC. This link includes some hints on how to set it up and points at a github gist with a simple html based RPC server that runs in a standalone.

或者,您可以启动一个完整的GUI Maya以使用命令端口进行控制,尽管这会大大降低测试速度.

Alternatively, you can just fire up a complete GUI Maya to control using commandport, although that will slow your tests down considerably.

这篇关于在独立的Maya中打开commandPort进行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 16:02