Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] interactive tests ensure output streams are flushed before quitting #1009

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions plugin/al/plugin/AL_USDMayaTestPlugin/py/testLayerManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from maya import cmds
from AL.usdmaya import ProxyShape

import fixturesUtils

class TestLayerManagerSerialisation(unittest.TestCase):
"""Test cases for layer manager serialisation and deserialisation"""

Expand Down Expand Up @@ -76,7 +78,7 @@ def test_editTargetSerialisation(self):
self._stage.DefinePrim(newPrimPath, "xform")
self._stage.SetEditTarget(self._stage.GetSessionLayer())

_tmpMayafile = tempfile.NamedTemporaryFile(delete=True, suffix=".ma")
_tmpMayafile = tempfile.NamedTemporaryFile(delete=True, suffix=".ma")
_tmpMayafile.close()

cmds.file(rename=_tmpMayafile.name)
Expand All @@ -97,7 +99,7 @@ def test_editTargetSerialisation(self):
def test_sessionLayerSerialisation(self):
""" A clean session layer should not be serialised on Maya scene save, nor we get
any complain form usdMaya on Maya scene reopen.
A dirty session layer should be serialised correctly on Maya scene save, and
A dirty session layer should be serialised correctly on Maya scene save, and
we should get it deserialised on Maya scene reopen. We should also be able to
reload on session layer to clear it.
"""
Expand Down Expand Up @@ -141,10 +143,5 @@ def test_sessionLayerSerialisation(self):
os.remove(_tmpMayafile.name)



if __name__ == "__main__":

tests = [unittest.TestLoader().loadTestsFromTestCase(TestLayerManagerSerialisation),]
results = [unittest.TextTestRunner(verbosity=2).run(test) for test in tests]
exitCode = int(not all([result.wasSuccessful() for result in results]))
cmds.quit(exitCode=(exitCode))
if __name__ == '__main__':
fixturesUtils.runTests(globals())
14 changes: 4 additions & 10 deletions plugin/al/plugin/AL_USDMayaTestPlugin/py/testProxyShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from maya import cmds
from maya.api import OpenMaya as om2

import fixturesUtils


class TestProxyShapeGetUsdPrimFromMayaPath(unittest.TestCase):
"""Test cases for static function: AL.usdmaya.ProxyShape.getUsdPrimFromMayaPath"""
Expand Down Expand Up @@ -424,13 +426,5 @@ def test_fromSessionLayer(self):
self.assertEqual(savedAttrValue, json.dumps(custom))


if __name__ == "__main__":

tests = [unittest.TestLoader().loadTestsFromTestCase(TestProxyShapeGetUsdPrimFromMayaPath),
unittest.TestLoader().loadTestsFromTestCase(TestProxyShapeGetMayaPathFromUsdPrim),
unittest.TestLoader().loadTestsFromTestCase(TestProxyShapeAnonymousLayer),
unittest.TestLoader().loadTestsFromTestCase(TestProxyShapeVariantFallbacks)
]
results = [unittest.TextTestRunner(verbosity=2).run(test) for test in tests]
exitCode = int(not all([result.wasSuccessful() for result in results]))
cmds.quit(exitCode=(exitCode))
if __name__ == '__main__':
fixturesUtils.runTests(globals())
50 changes: 23 additions & 27 deletions plugin/al/plugin/AL_USDMayaTestPlugin/py/testTranslators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

from pxr import Usd, UsdUtils, Tf

import fixturesUtils

class CubeGenerator(usdmaya.TranslatorBase):
'''
Basic Translator which doesn't support update
Expand All @@ -38,7 +40,7 @@ class CubeGenerator(usdmaya.TranslatorBase):
importObjectCount = 0
updateCount = 0
importObjectMObjects = []

@classmethod
def resetState(cls):
cls.initializeCount = 0
Expand All @@ -48,50 +50,50 @@ def resetState(cls):
cls.importObjectCount = 0
cls.updateCount = 0
cls.importObjectMObjects = []

@classmethod
def getState(cls):
return {"initializeCount": cls.initializeCount,
"preTearDownCount": cls.preTearDownCount,
"tearDownCount": cls.tearDownCount,
return {"initializeCount": cls.initializeCount,
"preTearDownCount": cls.preTearDownCount,
"tearDownCount": cls.tearDownCount,
"postImportCount":cls.postImportCount,
"importObjectCount":cls.importObjectCount,
"updateCount":cls.updateCount,
"importObjectMObjects":cls.importObjectMObjects }

def initialize(self):
return True

def preTearDown(self, prim):
self.__class__.preTearDownCount +=1
return True

def tearDown(self, path):
self.__class__.tearDownCount +=1
self.removeItems(path)
return True

def canExport(self, mayaObjectName):
return False

def needsTransformParent(self):
return True

def supportsUpdate(self):
return False

def importableByDefault(self):
return True

def exportObject(self, stage, path, usdPath, params):
return

def postImport(self, prim):
return True

def getTranslatedType(self):
return Tf.Type.Unknown


def importObject(self, prim, parent=None):
self.__class__.importObjectCount +=1
Expand All @@ -115,7 +117,7 @@ def importObject(self, prim, parent=None):

self.__class__.importObjectMObjects = self.context().getMObjectsPath(prim)
return True


def update(self, prim):
self.__class__.updateCount +=1
Expand Down Expand Up @@ -181,18 +183,18 @@ def exportObject(self, stage, path, usdPath, params):


class TestPythonTranslators(unittest.TestCase):

def setUp(self):
cmds.file(force=True, new=True)
cmds.loadPlugin("AL_USDMayaPlugin", quiet=True)
self.assertTrue(cmds.pluginInfo("AL_USDMayaPlugin", query=True, loaded=True))


def tearDown(self):
CubeGenerator.resetState()
UsdUtils.StageCache.Get().Clear()
usdmaya.TranslatorBase.clearTranslators()

def test_registration(self):
import examplecubetranslator #This registers the translator

Expand Down Expand Up @@ -675,11 +677,5 @@ def test_withSupportsUpdate(self):
self.assertTrue(cmds.objExists('|bindings_grp|root|dynamic_five_cubes'))


if __name__ == "__main__":

tests = [unittest.TestLoader().loadTestsFromTestCase(TestPythonTranslators)]
tests += [unittest.TestLoader().loadTestsFromTestCase(TestPythonTranslatorsUniqueKey)]

results = [unittest.TextTestRunner(verbosity=2).run(test) for test in tests]
exitCode = int(not all([result.wasSuccessful() for result in results]))
cmds.quit(force=True, exitCode=(exitCode))
if __name__ == '__main__':
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import sys
import unittest

import fixturesUtils


class testBatchRendererIsolateSelection(unittest.TestCase):

Expand Down Expand Up @@ -152,15 +154,4 @@ def testIsolateSelection(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testBatchRendererIsolateSelection)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import sys
import unittest

import fixturesUtils


class testPxrUsdMayaGLInstancerDraw(unittest.TestCase):

Expand Down Expand Up @@ -99,16 +101,6 @@ def testGenerateImages(self):
self._SetModelPanelsToViewport2()
self._WriteViewportImage("InstancerTest", "reload")


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testPxrUsdMayaGLInstancerDraw)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sys
import unittest

import fixturesUtils

class testRefAssemblyDrawRepresentations(unittest.TestCase):

Expand Down Expand Up @@ -91,15 +92,4 @@ def testDrawCubeRepresentations(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testRefAssemblyDrawRepresentations)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,4 @@ def testDrawAndTransformCube(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(testProxyShapeDrawAndTransform)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,4 @@ def testDrawAndToggleLightingMode(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testProxyShapeDrawColorAccuracy)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
13 changes: 1 addition & 12 deletions test/lib/mayaUsd/render/pxrUsdMayaGL/testProxyShapeDrawColors.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,4 @@ def _Snapshot(self, outName):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testProxyShapeDrawColors)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,4 @@ def testHydraTorusAndPlaneWithShadows(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testProxyShapeDrawLighting)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,4 @@ def testPerfGridOfCubeGridsModelRefs(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testProxyShapeDrawPerformance)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,4 @@ def testDrawAndToggleDrawPurposeAttributes(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(testProxyShapeDrawPurpose)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,4 @@ def testDrawAndChangeCurrentTime(self):


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(
testProxyShapeDrawTimeSampled)

results = unittest.TextTestRunner(stream=sys.__stderr__).run(suite)
if results.wasSuccessful():
exitCode = 0
else:
exitCode = 1
# maya running interactively often absorbs all the output. comment out the
# following to prevent maya from exiting and open the script editor to look
# at failures.
cmds.quit(abort=True, exitCode=exitCode)
fixturesUtils.runTests(globals())
Loading