Example #1
0
 def testStaticMethod(self):
     self.assertEqual(ExampleClass.sampleStaticMethod("a"), "a", "Expected static method to take the parameter I give as its first parameter")
     try:
         m = ExampleClass.oldIdiomStaticMethod("middle")
         self.assertEqual(m,"beforemiddleafter")
     except TypeError:
         self.fail("Issue #415 - Old idiom for static methods improperly checks first argument type")
     except:
         exc = sys.exc_info()
         self.fail("Issue #415?: %s" % exc[1])
         print sys.trackstackstr()
Example #2
0
 def testStaticMethod(self):
     self.assertEqual(
         ExampleClass.sampleStaticMethod("a"), "a",
         "Expected static method to take the parameter I give as its first parameter"
     )
     try:
         m = ExampleClass.oldIdiomStaticMethod("middle")
         self.assertEqual(m, "beforemiddleafter")
     except TypeError:
         self.fail(
             "Issue #415 - Old idiom for static methods improperly checks first argument type"
         )
     except:
         exc = sys.exc_info()
         self.fail("Issue #415?: %s" % exc[1])
         print sys.trackstackstr()
Example #3
0
    def formatException(self, ei):
        """
        Format and return the specified exception information as a string.

        This default implementation just uses
        traceback.print_exception()
        """
        if hasattr(sys, 'trackstackstr'):
            s = str(ei)
            s += sys.trackstackstr()
        else:
            import cStringIO
            import traceback
            sio = cStringIO.StringIO()
            traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
            s = sio.getvalue()
            sio.close()
        if s[-1:] == "\n":
            s = s[:-1]
        return s
Example #4
0
    def formatException(self, ei):
        """
        Format and return the specified exception information as a string.

        This default implementation just uses
        traceback.print_exception()
        """
        if hasattr(sys, 'trackstackstr'):
            s = str(ei)
            s += sys.trackstackstr()
        else:
            import cStringIO
            import traceback
            sio = cStringIO.StringIO()
            traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
            s = sio.getvalue()
            sio.close()
        if s[-1:] == "\n":
            s = s[:-1]
        return s