How to use _logCalls method in fMBT

Best Python code snippet using fMBT_python

fmbtlogger.py

Source:fmbtlogger.py Github

copy

Full Screen

...149 raise TypeError("LogWriter instance expected as the second parameter")150 if type(obj) in [types.TypeType, types.ClassType]:151 return _logInstances(obj, logWriter, logDepth)152 else:153 return _logCalls(obj, logWriter, logDepth)154def _logInstances(orig_class, report, logDepth):155 def _detectInstantiations(*args, **kwargs):156 orig_self = orig_class(*args, **kwargs)157 return _logCalls(orig_self, report, logDepth)158 return _detectInstantiations159def _logCalls(orig_self, report, logDepth_):160 """161 logger(object) starts logging method calls of the object162 """163 class localVars: pass164 localVars.logDepth = logDepth_165 localVars.testStep = -1166 localVars.actionName = None167 def logMethodCall(func, throughInstance = None):168 def callee(*args, **kwargs):169 currentTestStep = fmbt.getTestStep()170 if localVars.testStep != currentTestStep:171 if localVars.actionName not in [None, "undefined"]:172 report.end(localVars.actionName)173 localVars.testStep = currentTestStep...

Full Screen

Full Screen

errorhandler.py

Source:errorhandler.py Github

copy

Full Screen

1#!/usr/bin/env python2"""cssutils ErrorHandler34ErrorHandler5 used as log with usual levels (debug, info, warn, error)67 if instanciated with ``raiseExceptions=True`` raises exeptions instead8 of logging910log11 defaults to instance of ErrorHandler for any kind of log message from12 lexerm, parser etc.1314 - raiseExceptions = [False, True]15 - setloglevel(loglevel)16"""17__all__ = ['ErrorHandler']18__docformat__ = 'restructuredtext'19__author__ = '$LastChangedBy: cthedot $'20__date__ = '$LastChangedDate: 2007-10-18 22:43:15 +0200 (Do, 18 Okt 2007) $'21__version__ = '$LastChangedRevision: 503 $'2223import logging24import xml.dom2526class _ErrorHandler(object):27 """28 handles all errors and log messages29 """3031 def __init__(self, log,32 defaultloglevel=logging.DEBUG, raiseExceptions=False):33 """34 inits log if none given3536 log37 for parse messages, default logs to sys.stderr38 defaultloglevel39 if none give this is logging.DEBUG40 raiseExceptions41 - True: Errors will be reported to the calling app,42 e.g. during building43 - False: Errors will be written to the log, this is the44 default behaviour when parsing45 """46 if log:47 self._log = log48 else:49 import sys50 self._log = logging.getLogger('CSSUTILS')51 hdlr = logging.StreamHandler(sys.stderr)52 formatter = logging.Formatter('%(levelname)s\t%(message)s')53 hdlr.setFormatter(formatter)54 self._log.addHandler(hdlr)55 self._log.setLevel(defaultloglevel)5657 self.raiseExceptions = raiseExceptions585960 def __getattr__(self, name):61 # here if new log has been set62 _logcalls = {63 u'debug': self._log.debug,64 u'info': self._log.info,65 u'warn': self._log.warn,66 u'critical': self._log.critical,67 u'fatal': self._log.fatal,68 u'error': self._log.error69 }7071 if name in _logcalls.keys():72 self._logcall = _logcalls[name]73 return self.__handle74 else:75 raise AttributeError(76 '(errorhandler) No Attribute "%s" found' % name)777879 def setlog(self, log):80 """set log of errorhandler's log"""81 self._log = log828384 def setloglevel(self, level):85 """set level of errorhandler's log"""86 self._log.setLevel(level)878889 def __handle(self, msg=u'', token=None, error=xml.dom.SyntaxErr,90 neverraise=False):91 """92 handles all calls93 logs or raises exception94 """95 if token:96 if isinstance(token, tuple):97 msg = u'%s [%s:%s: %s]' % (98 msg, token[2], token[3], token[1])99 else:100 msg = u'%s [%s:%s: %s]' % (101 msg, token.line, token.col, token.value)102103 if error and self.raiseExceptions and not neverraise:104 raise error(msg)105 else:106 self._logcall(msg)107108109class ErrorHandler(_ErrorHandler):110 "Singleton, see _ErrorHandler"111112 instance = None113114 def __init__(self,115 log=None, defaultloglevel=logging.INFO, raiseExceptions=True):116117 if ErrorHandler.instance is None:118 ErrorHandler.instance = _ErrorHandler(log=log,119 defaultloglevel=defaultloglevel,120 raiseExceptions=raiseExceptions) ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful