def testCase12a(): print("Case12a: include string error but exclude from path - aborts") delegate = delegateSetup(["please"], None, None, ["*usdImaging*"]) try: Tf.RaiseCodingError("does not abort - not in usdImaging") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("lets not abort - not in usdImaging") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("abort please - not in usdImaging") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase13a(): print("Case13a: include codePath error but exclude from string - aborts") delegate = delegateSetup(None, ["*test*"], ["*not*"], None) try: Tf.RaiseCodingError("does not abort - word not excluded") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("lets not abort - word not excluded") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("abort please - word excluded") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase6(): print("Case6: Exclude some but abort on at least one string error") delegate = delegateSetup(["*abort*"], None, ["*not*"], None) try: Tf.RaiseCodingError("does not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("aborting on this!!") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase4(): print("Case4: Empty lists of inclusion filters for string errors") delegate = delegateSetup(None, None, ["blah"], None) try: Tf.RaiseCodingError("") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase3(): print("Case3: Empty lists of error filters") delegate = delegateSetup(None, None, None, None) try: Tf.RaiseCodingError("") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase2(): print("Case2: Ignore all string errors") delegate = delegateSetup(["*"], None, ["*"], None) try: Tf.RaiseCodingError("") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase12(): print( "Case12: include string error but exclude from path - does not abort") delegate = delegateSetup(["*"], None, None, ["*test*"]) try: Tf.RaiseCodingError("does not abort - nothing in pxr is aborted") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("lets not abort - nothing in pxr is aborted") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("abort not please - nothing in pxr is aborted") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase11a(): print("Case11a: All string errors consumed by exclude list without using " "glob") delegate = delegateSetup(None, ["ConditionalAbort"], None, ["*test*"]) try: Tf.RaiseCodingError("does not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("lets not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("abort not please") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase11(): print("Case11: Exclude some but abort on at least one codePath error") # Note this is done using string exclude filters delegate = delegateSetup(None, ["*test*"], ["*not*"], None) try: Tf.RaiseCodingError("does not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("not abort") except Tf.ErrorException as e: Tf.RepostErrors(e) try: Tf.RaiseCodingError("aborting on this!!") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase8(): print("Case8: Ignore all codePath errors") delegate = delegateSetup(None, ["*"], None, ["*"]) try: Tf.RaiseCodingError("") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testError(self): """Simulate error in non-Python-invoked code by using Tf.RepostErrors.""" self._StartRecording() try: Tf.RaiseCodingError("blah") except Tf.ErrorException as e: Tf.RepostErrors(e) log = self._StopRecording() self.assertEqual(len(log), 1) logText, logCode = log[0] # When this test is executed as a result of the unittest.main() call at # the bottom of this file (e.g. when this script is executed directly # via the shebang, when the script file is passed to a Python # interpreter on the command-line, or when the script file's contents # is read and executed through compile() and exec(), the module will be # reported as "__main__". Otherwise, when this file is imported as a # module and then executed using unittest.main(module=<module name>), # the module name will match the file name and be reported as # "testDiagnosticDelegate". We make the regex here recognize both # cases. if (Tf.GetEnvSetting('MAYAUSD_SHOW_FULL_DIAGNOSTICS')): self.assertRegex( logText, "^Python coding error: blah -- Coding Error in " "(__main__|testDiagnosticDelegate)\.testError at line [0-9]+ of " ) else: self.assertEqual(logText, "Python coding error: blah") self.assertEqual(logCode, OM.MCommandMessage.kError)
def testCase5a(): print("Case5a: Empty lists of exclude filters for string errors, include " "list does contain error") delegate = delegateSetup(["*included*"], None, None, None) try: Tf.RaiseCodingError("error string included") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase5(): print("Case5: Empty lists of exclude filters for string errors, include " "list does not contain any error") delegate = delegateSetup(["blah"], None, None, None) try: Tf.RaiseCodingError("error string not included") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testCase10a(): print("Case10a: Empty lists of exclude filters for codePath errors, " "include list does contain error") delegate = delegateSetup(None, ["*test*"], None, None) try: Tf.RaiseCodingError("codePath included") except Tf.ErrorException as e: Tf.RepostErrors(e)
def testError(self): """Simulate error in non-Python-invoked code by using Tf.RepostErrors.""" self._StartRecording() try: Tf.RaiseCodingError("blah") except Tf.ErrorException as e: Tf.RepostErrors(e) log = self._StopRecording() self.assertEqual(len(log), 1) logText, logCode = log[0] self.assertRegexpMatches(logText, "^Python coding error: blah -- Coding Error in " "__main__\.testError at line [0-9]+ of ") self.assertEqual(logCode, OM.MCommandMessage.kError)