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

Fix tests that are modifying source folder. #3802

Merged
merged 1 commit into from
Jun 4, 2024
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
20 changes: 14 additions & 6 deletions test/lib/mayaUsd/nodes/testProxyShapeBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')

Expand All @@ -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):
'''
Expand Down Expand Up @@ -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')

Expand Down
9 changes: 5 additions & 4 deletions test/lib/usd/translators/testUsdExportTexture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down