def printCurStack(): r''' Prints the full current stack of Python as well as additional information as specified by the value of _verbosity in the same class. This will not print the first two elements on top of the stack, which will contain this method as well as the class frame. This relies on _debug to tell it if it should print out its header and trailer. See the docstring for the class for further information on _verbosity. ''' _debug = pyDecorator._debug i = 2 if _debug: pyDecorator.__print( '>>pyDecorator:printCurStack called. Unrolling stack...\n' ) try: if _getframe: # With this loop we continue to trace down the stack until we are # unable to. In that event, we create a ValueError exception and # thus exit outside the loop while True: pyDecorator.printCurFrame(i) i += 1 else: pyDecorator.__print( '>>Number of functions already called %i' % callstats()[0] ) except ValueError: pass if _debug: pyDecorator.__print( '\n\npyDecorator:printCurStack finished' )
def test_success_mock_sys_function(self): self.mock.mock_function(sys.callstats).and_return(1) self.assertEqual(1, sys.callstats()) self.mock.tearDown() self.assertEqual(None, sys.callstats())
#encoding:utf-8 import sys res = sys.path res = sys.argv #['D:/PycharmProjects/OldBoyPythonLearn/20180522/module/sys_test.py'] res = sys.getdefaultencoding() #utf-8 res = sys.api_version #1013 res = sys.callstats() print(res)
def test(*args, **kwargs): print(sys.api_version) print(sys.argv) print(sys.callstats()) print(sys.getfilesystemencoding()) print(sys.exc_info())