Our setup is pretty simple, we do all of our unittesting from Wing using Nose. This is actually another reason i like the sitecustomize pattern, this way I know that the environment my unittests are running under is pretty much the same environment the production code is going to run under (except for Mobu, since at least Mobu 2010 or 2011, i forget which, didn’t do an import site, or somethign to taht effect, basically whatever version it was wouldn’t hook a sitecustomize).
So basically, sitecustomize, then take advantage of the setUp() and tearDown() methods to do all your DCC specific stuff like test scene setup, etc. For example:
import unittest
import pymel.core as pm
class TestANode(unittest.TestCase):
def setUp(self):
#this is also where you could open a file
#say you had a unittest character or asset
pm.newFile(force=True)
#this is just an example
self.test_node = pm.createNode('network')
So now all your tests can reference self.test_node or whatever. Pretty straightforward no-brainer pattern. You may not actually need a tearDown() in most cases, i’ll have to go back through some of my unittests and see what specific cases exist, i can make up a few off the top of my head, but i know i have some actual real cases. You can run this using commandline runners or scripts as well, as long as your interpreter is setup to play nice with Maya or whatever else. Hope that helps, this is super simple and i’m sure there are better ways to do it, but this’ll get you up and running pretty quick.