diff --git a/test/lib/mayaUsd/nodes/testProxyShapeBase.py b/test/lib/mayaUsd/nodes/testProxyShapeBase.py index 85fe9a1d1f..6cf1cb2b76 100644 --- a/test/lib/mayaUsd/nodes/testProxyShapeBase.py +++ b/test/lib/mayaUsd/nodes/testProxyShapeBase.py @@ -982,7 +982,7 @@ def testCachedStage(self): stageCache = UsdUtils.StageCache.Get() with Usd.StageCacheContext(stageCache): cachedStage = Usd.Stage.Open(self.usdFilePath) - + stageId = stageCache.GetId(cachedStage).ToLongInt() shapeNode = cmds.createNode('mayaUsdProxyShape') cmds.setAttr('{}.stageCacheId'.format(shapeNode), stageId) @@ -994,16 +994,20 @@ def testCachedStage(self): cmds.move(0, 0, 2, r=True) # Make sure shareStage is ON - assert cmds.getAttr('{}.{}'.format(shapeNode,"shareStage")) + self.assertTrue(cmds.getAttr('{}.{}'.format(shapeNode,"shareStage"))) # Make sure there is no connection to inStageData - assert not cmds.listConnections('{}.inStageData'.format(shapeNode), s=True, d=False) + self.assertIsNone(cmds.listConnections('{}.inStageData'.format(shapeNode), s=True, d=False)) cmds.select(cmds.listRelatives(fullPath, p=True)[0], r=True) with testUtils.TemporaryDirectory(prefix='ProxyShapeBase') as testDir: pathToSave = "{}/CubeModel.ma".format(testDir) + # Make sure to save USD back to Maya file, so that the USD test + # file we loaded (from source folder) isn't modified. + cmds.optionVar(intValue=('mayaUsd_SerializedUsdEditsLocation', 2)) + cmds.file(rename=pathToSave) cmds.file(save=True, force=True, type='mayaAscii') @@ -1012,12 +1016,12 @@ def testCachedStage(self): stage = mayaUsd.lib.GetPrim(fullPath).GetStage() prim = stage.GetPrimAtPath('/CubeModel') - assert prim.IsValid() - + self.assertTrue(prim.IsValid()) + # Verify we get the saved changes we did xform = UsdGeom.Xformable(prim) translate = xform.GetOrderedXformOps()[0].Get() - assert translate[2] == 2 + self.assertEqual(translate[2], 2) def testRegisterFilePathEditor(self): ''' @@ -1101,6 +1105,10 @@ def _verifyVariantFallbacks(primPath, stage, shapeNode, overrides): with testUtils.TemporaryDirectory(prefix='ProxyShapeBase') as testDir: pathToSave = "{}/testSavingVariantFallbacks.ma".format(testDir) + # Make sure to save USD back to Maya file, so that the USD test + # file we loaded (from source folder) isn't modified. + cmds.optionVar(intValue=('mayaUsd_SerializedUsdEditsLocation', 2)) + cmds.file(rename=pathToSave) cmds.file(save=True, force=True, type='mayaAscii') diff --git a/test/lib/usd/translators/testUsdExportTexture.py b/test/lib/usd/translators/testUsdExportTexture.py index 46e95e57fc..4f7e2a7903 100644 --- a/test/lib/usd/translators/testUsdExportTexture.py +++ b/test/lib/usd/translators/testUsdExportTexture.py @@ -49,13 +49,14 @@ def getUsdFilePath(self): return os.path.join(outputFolder, 'TextureTest.usda') def tearDown(self): - usdFilePath = self.getUsdFilePath() try: - if os.path.exists(usdFilePath): - os.remove(usdFilePath) + # Cleanup the output folder added for the test. We don't want + # to leave extra files around in the test source directory. + outputFolder = os.path.dirname(self.getUsdFilePath()) + import shutil + shutil.rmtree(outputFolder) except Exception: # Don't let cleanup errors fail the test. - # We're removing the output file only to be nice, it is not mandatory. pass def runTextureTest(self, relativeMode, withEnvVar):