当前位置: 首页>>代码示例>>Python>>正文


Python loggerForTest.TestingLogger类代码示例

本文整理汇总了Python中socorro.unittest.testlib.loggerForTest.TestingLogger的典型用法代码示例。如果您正苦于以下问题:Python TestingLogger类的具体用法?Python TestingLogger怎么用?Python TestingLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestingLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testReportExceptionAndContinue

 def testReportExceptionAndContinue(self):
   logger = TestingLogger()
   util.reportExceptionAndContinue(logger)
   assert(3 == len(logger.levels))
   assert([logging.ERROR, logging.ERROR, logging.INFO] == logger.levels)
   assert("MainThread Caught Error: None" == logger.buffer[0])
   assert('' == logger.buffer[1])
   assert("trace back follows:" in logger.buffer[2])
   logger.clear()
   util.reportExceptionAndContinue(logger, loggingLevel=-39)
   assert(3 == len(logger.levels))
   assert([-39, -39, logging.INFO] == logger.levels)
   assert("MainThread Caught Error: None" == logger.buffer[0])
   assert('' == logger.buffer[1])
   assert("trace back follows:" in logger.buffer[2])
   logger.clear()
   util.reportExceptionAndContinue(logger, ignoreFunction = ignoreAlways)
   assert([] == logger.levels)
   try:
     raise TestingException("test message")
   except TestingException, e:
     util.reportExceptionAndContinue(logger, loggingLevel=-12)
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:22,代码来源:testutil.py

示例2: testReportExceptionAndContinue

 def testReportExceptionAndContinue(self):
   logger = TestingLogger()
   util.reportExceptionAndContinue(logger)
   assert(4 == len(logger.levels))
   assert([logging.ERROR, logging.ERROR, logging.ERROR, logging.ERROR] == logger.levels)
   #print logger.buffer
   assert("Caught Error: None" == logger.buffer[0])
   assert('None' == logger.buffer[1]), "expected 'None' but got %s" % logger.buffer[1]
   assert("trace back follows:" in logger.buffer[2])
   logger.clear()
   util.reportExceptionAndContinue(logger, loggingLevel=-39)
   assert(4 == len(logger.levels))
   assert([-39, -39, -39, -39] == logger.levels)
   assert("Caught Error: None" == logger.buffer[0])
   assert('None' == logger.buffer[1])
   assert("trace back follows:" in logger.buffer[2])
   logger.clear()
   util.reportExceptionAndContinue(logger, ignoreFunction = ignoreAlways)
   assert([] == logger.levels)
   try:
     raise TestingException("test message")
   except TestingException, e:
     util.reportExceptionAndContinue(logger, loggingLevel=-12)
开发者ID:Meghashyamt,项目名称:socorro,代码行数:23,代码来源:testutil.py

示例3: testWarn

def testWarn():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.warn("warn")
  tlb.warn("warn")
  assert (logging.WARN,'warn',()) == bl.item
  assert logging.WARN == tl.levels[0]
  assert logging.WARN == tlb.levels[0]
  assert 'warn' == tl.buffer[0]
  assert 'warn' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例4: testWarning

def testWarning():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.warning("warning")
  tlb.warning("warning")
  assert (logging.WARNING,'warning',()) == bl.item
  assert logging.WARNING == tl.levels[0]
  assert logging.WARNING == tlb.levels[0]
  assert 'warning' == tl.buffer[0]
  assert 'warning' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例5: testFatal

def testFatal():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.fatal("fatal")
  tlb.fatal("fatal")
  assert (logging.FATAL,'fatal',()) == bl.item
  assert logging.FATAL == tl.levels[0]
  assert logging.FATAL == tlb.levels[0]
  assert 'fatal' == tl.buffer[0]
  assert 'fatal' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例6: testDebug

def testDebug():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.debug("bug")
  tlb.debug("bug")
  assert (logging.DEBUG,'bug',()) == bl.item
  assert logging.DEBUG == tl.levels[0]
  assert logging.DEBUG == tlb.levels[0]
  assert 'bug' == tl.buffer[0]
  assert 'bug' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例7: testInfo

def testInfo():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.info("info")
  tlb.info("info")
  assert (logging.INFO,'info',()) == bl.item
  assert logging.INFO == tl.levels[0]
  assert logging.INFO == tlb.levels[0]
  assert 'info' == tl.buffer[0]
  assert 'info' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例8: testCritical

def testCritical():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.critical("critical")
  tlb.critical("critical")
  assert (logging.CRITICAL,'critical',()) == bl.item
  assert logging.CRITICAL == tl.levels[0]
  assert logging.CRITICAL == tlb.levels[0]
  assert 'critical' == tl.buffer[0]
  assert 'critical' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例9: testError

def testError():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.error("error")
  tlb.error("error")
  assert (logging.ERROR,'error',()) == bl.item
  assert logging.ERROR == tl.levels[0]
  assert logging.ERROR == tlb.levels[0]
  assert 'error' == tl.buffer[0]
  assert 'error' == tlb.buffer[0]
开发者ID:Manchester412,项目名称:socorro,代码行数:11,代码来源:testLoggerForTest.py

示例10: setUp

  def setUp(self):
    global me
    self.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing builds')

    myDir = os.path.split(__file__)[0]
    if not myDir: myDir = '.'
    replDict = {'testDir':'%s'%myDir}
    for i in self.config:
      try:
        self.config[i] = self.config.get(i)%(replDict)
      except:
        pass
    self.logger = TestingLogger(me.fileLogger)

    self.testConfig = configurationManager.Config([('t','testPath', True, './TEST-BUILDS', ''),
                                                   ('f','testFileName', True, 'lastrun.pickle', ''),
                                                  ])
    self.testConfig["persistentDataPathname"] = os.path.join(self.testConfig.testPath, self.testConfig.testFileName)
开发者ID:AlinT,项目名称:socorro,代码行数:18,代码来源:testBuilds.py

示例11: setUp

  def setUp(self):
    global me
    self.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing MTBF')
    
    myDir = os.path.split(__file__)[0]
    if not myDir: myDir = '.'
    replDict = {'testDir':'%s'%myDir}
    for i in self.config:
      try:
        self.config[i] = self.config.get(i)%(replDict)
      except:
        pass
    self.logger = TestingLogger(me.fileLogger)
    self.connection = psycopg2.connect(me.dsn)
    cursor = self.connection.cursor()
    self.testDB = TestDB()
    self.testDB.removeDB(self.config,self.logger)

    self.testDB.createDB(self.config,self.logger)
    self.prods = ['zorro','vogel','lizz',]
    self.oss = ['OSX','LOX','WOX',]
    self.productDimData = [] # filled in by fillMtbfTables
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:22,代码来源:testMtbf.py

示例12: testLog

def testLog():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  for level in range(0,60,10):
    tl.log(level,'message')
    tlb.log(level,'message')
    assert 'message' == tl.buffer[-1]
    assert level == tl.levels[-1]
    assert (level,'message',()) == bl.item
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  for level in range(0,60,10):
    tl.log(level,'message %s %s','one','two')
    tlb.log(level,'message %s %s','one','two')
    assert 'message one two' == tl.buffer[-1]
    assert (level,'message %s %s',('one','two')) == bl.item
开发者ID:Manchester412,项目名称:socorro,代码行数:17,代码来源:testLoggerForTest.py

示例13: testClear

def testClear():
  tl = TestingLogger()
  tl.clear()
  assert 0 == len(tl)
  assert 0 == len(tl.levels)
  assert 0 == len(tl.buffer)

  tl.debug('woo')
  tl.info('woo')
  tl.warning('woo')
  tl.warn('woo')
  tl.error('woo')
  tl.critical('woo')
  tl.fatal('woo')

  assert 7 == len(tl)
  assert 7 == len(tl.levels)
  assert 7 == len(tl.buffer)

  tl.clear()
  assert 0 == len(tl)
  assert 0 == len(tl.levels)
  assert 0 == len(tl.buffer)
开发者ID:Manchester412,项目名称:socorro,代码行数:23,代码来源:testLoggerForTest.py

示例14: testLenFunction

def testLenFunction():
  tl = TestingLogger()
  exp = 0
  assert exp == len(tl)
  tl.debug('woo')
  exp += 1
  assert exp == len(tl)
  tl.info('woo')
  exp += 1
  assert exp == len(tl)
  tl.warning('woo')
  exp += 1
  assert exp == len(tl)
  tl.warn('woo')
  exp += 1
  assert exp == len(tl)
  tl.error('woo')
  exp += 1
  assert exp == len(tl)
  tl.critical('woo')
  exp += 1
  assert exp == len(tl)
  tl.fatal('woo')
  exp += 1
  assert exp == len(tl)
开发者ID:Manchester412,项目名称:socorro,代码行数:25,代码来源:testLoggerForTest.py

示例15: TestMtbf

class TestMtbf(unittest.TestCase):
  def setUp(self):
    global me
    self.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing MTBF')
    
    myDir = os.path.split(__file__)[0]
    if not myDir: myDir = '.'
    replDict = {'testDir':'%s'%myDir}
    for i in self.config:
      try:
        self.config[i] = self.config.get(i)%(replDict)
      except:
        pass
    self.logger = TestingLogger(me.fileLogger)
    self.connection = psycopg2.connect(me.dsn)
    cursor = self.connection.cursor()
    self.testDB = TestDB()
    self.testDB.removeDB(self.config,self.logger)

    self.testDB.createDB(self.config,self.logger)
    self.prods = ['zorro','vogel','lizz',]
    self.oss = ['OSX','LOX','WOX',]
    self.productDimData = [] # filled in by fillMtbfTables
    
  def tearDown(self):
    self.testDB.removeDB(self.config,self.logger)
    self.logger.clear()

  def fillMtbfTables(self,cursor):
    """
    Need some data to test with. Here's where we make it out of whole cloth...
    """
    # (id),product,version,os,release : what product is it, by id
    self.productDimData = [ [self.prods[p],'%s.1.%s'%(p,r), self.oss[o], 'beta-%s'%r] for p in range(2) for o in range(2) for r in range(1,4) ]
    cursor.executemany('INSERT into productdims (product,version,os_name,release) values (%s,%s,%s,%s)',self.productDimData)
    cursor.connection.commit()
    cursor.execute("SELECT id, product,version, os_name, release from productdims")
    productDimData = cursor.fetchall()
    cursor.connection.commit()
    self.baseDate = dt.date(2008,1,1)
    self.intervals = {
      '0.1.1':(self.baseDate                        ,self.baseDate+dt.timedelta(days=30)),
      '0.1.2':(self.baseDate + dt.timedelta(days=10),self.baseDate + dt.timedelta(days=40)),
      '0.1.3':(self.baseDate + dt.timedelta(days=20),self.baseDate + dt.timedelta(days=50)),
      '1.1.1':(self.baseDate + dt.timedelta(days=10),self.baseDate + dt.timedelta(days=40)),
      '1.1.2':(self.baseDate + dt.timedelta(days=20),self.baseDate + dt.timedelta(days=50)),
      '1.1.3':(self.baseDate + dt.timedelta(days=30),self.baseDate + dt.timedelta(days=60)),
      }
    # processing days are located at and beyond the extremes of the full range, and
    # at some interior points, midway between each pair of interior points
    # layout is: (a date, the day-offset from baseDate, the expected resulting [ids])
    PDindexes = [-1,0,5,10,15,25,35,45,55,60,61]
    productsInProcessingDay = [
      [], #  -1,
      [1,4],#  0,
      [1,4],#  5,
      [1,2,4,5,7,10],#  10,
      [1,2,4,5,7,10],#  15,
      [1,2,3,4,5,6,7,8,10,11],#  25,
      [2,3,5,6,7,8,9,10,11,12],#  35,
      [3,6,8,9,11,12],#  45,
      [9,12],#  55,
      [9,12],#  60,
      [],#  61,
      ]
    self.processingDays = [ (self.baseDate+dt.timedelta(days=PDindexes[x]),PDindexes[x],productsInProcessingDay[x]) for x in range(len(PDindexes))]
    
    # (id), productdims_id, start_dt, end_dt : Date-interval when product is interesting
    configData =[ (x[0],self.intervals[x[2]][0],self.intervals[x[2]][1] ) for x in productDimData ]
    cursor.executemany('insert into mtbfconfig (productdims_id,start_dt,end_dt) values(%s,%s,%s)',configData)
    cursor.connection.commit()

    self.expectedFacts = {
      # key is offset from baseDate
      # value is array of (productDims_id,day,avg_seconds,report_count,count(distinct(user))
      # This data WAS NOT CALCULATED BY HAND: The test was run once with prints in place
      # and that output was encoded here. As of 2009-Feb, count of unique users is always 0
      -1: [],
      0: [
      (1, dt.date(2008,1,1), 5, 6, 0),
      (4, dt.date(2008,1,1), 20, 6, 0),
      ],
      5: [
      (1, dt.date(2008,1,6), 5, 6, 0),
      (4, dt.date(2008,1,6), 20, 6, 0),
      ],
      10: [
      (1, dt.date(2008,1,11), 5, 6, 0),
      (2, dt.date(2008,1,11), 10, 6, 0),
      (4, dt.date(2008,1,11), 20, 6, 0),
      (5, dt.date(2008,1,11), 25, 6, 0),
      (7, dt.date(2008,1,11), 35, 6, 0),
      (10, dt.date(2008,1,11), 50, 6, 0),
      ],
      15: [
      (1, dt.date(2008,1,16), 5, 6, 0),
      (2, dt.date(2008,1,16), 10, 6, 0),
      (4, dt.date(2008,1,16), 20, 6, 0),
      (5, dt.date(2008,1,16), 25, 6, 0),
      (7, dt.date(2008,1,16), 35, 6, 0),
#.........这里部分代码省略.........
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:101,代码来源:testMtbf.py


注:本文中的socorro.unittest.testlib.loggerForTest.TestingLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。