def testBatching_BatchCount(self): """Tests the GetBatchCount() debugging function.""" count = -1 with UsdMaya.DiagnosticBatchContext(): with UsdMaya.DiagnosticBatchContext(): count = UsdMaya.DiagnosticDelegate.GetBatchCount() self.assertEqual(count, 2) count = UsdMaya.DiagnosticDelegate.GetBatchCount() self.assertEqual(count, 0)
def testBatching(self): self._StartRecording() with UsdMaya.DiagnosticBatchContext(): Tf.Warn("spooky warning") Tf.Status("informative status") for i in xrange(5): Tf.Status("repeated status %d" % i) for i in xrange(3): Tf.Warn("spam warning %d" % i) try: Tf.RaiseCodingError("coding error!") except: pass log = self._StopRecording() # Note: we use assertItemsEqual because coalescing may re-order the # diagnostic messages. self.assertItemsEqual( log, [("spooky warning", OM.MCommandMessage.kWarning), ("informative status", OM.MCommandMessage.kInfo), ("repeated status 0 -- and 4 similar", OM.MCommandMessage.kInfo), ("spam warning 0 -- and 2 similar", OM.MCommandMessage.kWarning)])
def testBatching_DelegateRemoved(self): """Tests removing the diagnostic delegate when the batch context is still open.""" self._StartRecording() with UsdMaya.DiagnosticBatchContext(): Tf.Warn("this warning won't be lost") Tf.Status("this status won't be lost") cmds.unloadPlugin('pxrUsd', force=True) for i in xrange(5): Tf.Status("no delegate, this will be lost %d" % i) log = self._StopRecording() # Note: we use assertItemsEqual because coalescing may re-order the # diagnostic messages. self.assertItemsEqual(log, [ ("this warning won't be lost", OM.MCommandMessage.kWarning), ("this status won't be lost", OM.MCommandMessage.kInfo), ])