DCCs
Code in visual effects pipelines interacts with DCCs to automate or improve workflows. A typical example is to load and save files automatically. To achieve that, our code provides the logic to load and save the files into their correct locations and needs to interact with the DCC API to control the DCC. This dependency on the DCC API leads to some issues during tests. Because the code requires the DCC API, it has to be executed inside a DCC. But since we want to run our unit tests very fast, this is not an option. Especially if our code is focusing heavily on logic and only has simple DCC API calls, this is a waste of time and slows down the developer.
To make our tests fast, we encapsulate calls to the DCC API in a class and wrap the DCC API. The methods should be wrapped in a way which makes them “too simple to fail” , for example:
import pymel.core as pm
class MayaWrapper(object):
def new_scene():
pm.newScene()
We can assume that pm.newScene()
is very stable and will never break.
This solution is only intended for logic heavy code (for example asset management, publishing or render farm submission). Wrapping complex data types such as transforms or meshes makes the code too complicated and can lead to performance issues. See the Arnold Subdiv Manager for a complex example.