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


Python TestingLogger.clear方法代码示例

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


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

示例1: testReportExceptionAndContinue

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
 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,代码行数:24,代码来源:testutil.py

示例2: testReportExceptionAndContinue

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
 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,代码行数:25,代码来源:testutil.py

示例3: testClear

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
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,代码行数:25,代码来源:testLoggerForTest.py

示例4: TestBugzilla

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
class TestBugzilla(unittest.TestCase):
  def setUp(self):
    global me
    self.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing bugzilla')

    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 = me.database.connection()
    #self.connection = psycopg2.connect(me.dsn)

    self.testConfig = configurationManager.Config([('t','testPath', True, './TEST-BUGZILLA', ''),
                                                  ('f','testFileName', True, 'lastrun.pickle', ''),
                                                  ('', 'daysIntoPast', True, 0),])
    self.testConfig["persistentDataPathname"] = os.path.join(self.testConfig.testPath, self.testConfig.testFileName)

  def tearDown(self):
    self.logger.clear()

  def test_bugzilla_iterator(self):
    csv = ['bug_id,"bug_status","resolution","short_desc","cf_crash_signature"\n',
           '1,"RESOLVED",,"this is a comment","This sig, while bogus, has a ] bracket"',
           '2,"CLOSED","WONTFIX","comments are not too important","single [@ BogusClass::bogus_sig (const char**) ] signature"',
           '3,"ASSIGNED",,"this is a comment. [@ nanojit::LIns::isTramp()]","[@ [email protected]] [@ [email protected]]"',
           '4,"CLOSED","RESOLVED","two sigs enter, one sig leaves","[@ layers::[email protected]] [@ layers::[email protected]]"',
           '5,"ASSIGNED","INCOMPLETE",,"[@ [email protected]] and a broken one [@ [email protected]"',
           '6,"ASSIGNED",,"empty crash sigs should not throw errors",""',
           '7,"CLOSED",,"gt 525355 gt","[@gfx::font(nsTArray<nsRefPtr<FontEntry> > const&)]"',
           '8,"CLOSED","RESOLVED","newlines in sigs","[@ legitimate(sig)] \n junk \n [@ another::legitimate(sig) ]"'
          ]
    correct = [ (1, "RESOLVED", "", "this is a comment", set([])),
                (2, "CLOSED", "WONTFIX", "comments are not too important", set(["BogusClass::bogus_sig (const char**)"])),
                (3, "ASSIGNED", "", "this is a comment. [@ nanojit::LIns::isTramp()]",
                 set(["[email protected]", "[email protected]"])),
                (4, "CLOSED", "RESOLVED", "two sigs enter, one sig leaves", set(["layers::[email protected]"])),
                (5, "ASSIGNED", "INCOMPLETE", "", set(["[email protected]"])),
                (6, "ASSIGNED", "", "empty crash sigs should not throw errors", set([])),
                (7, "CLOSED", "", "gt 525355 gt", set(["gfx::font(nsTArray<nsRefPtr<FontEntry> > const&)"])),
                (8, "CLOSED", "RESOLVED", "newlines in sigs", set(['another::legitimate(sig)', 'legitimate(sig)']))
              ]
    for expected, actual in zip(bug.bugzilla_iterator(csv, iter), correct):
      assert expected == actual, "expected %s, got %s" % (str(expected), str(actual))

  def test_signature_is_found(self):
    global me
    assert bug.signature_is_found("[email protected]", me.cur)
    assert not bug.signature_is_found("sir_not_appearing_in_this_film", me.cur)
    me.cur.connection.rollback()

  def verify_tables(self, correct):
    global me
    # bug_status
    count = 0
    for expected, actual in zip(psy.execute(me.cur, "select id, status, resolution, short_desc from bugs order by 1"), correct["bugs"]):
      count += 1
      assert expected == actual, "expected %s, got %s" % (str(expected), str(actual))
    assert len(correct["bugs"]) == count, "expected %d entries in bugs but found %d" % (len(correct["bugs"]), count)
    #bug_associations
    count = 0
    for expected, actual in zip(psy.execute(me.cur, "select signature, bug_id from bug_associations order by 1, 2"), correct["bug_associations"]):
      count += 1
      assert expected == actual, "expected %s, got %s" % (str(expected), str(actual))
    assert len(correct["bug_associations"]) == count, "expected %d entries in bug_associations but found %d" % (len(correct["bug_associations"]), count)

  def test_insert_or_update_bug_in_database(self):
    #bugId, statusFromBugzilla, resolutionFromBugzilla, signatureListFromBugzilla
    #new    *                   *                       empty
    #new    *                   *                       1 new
    #new    *                   *                       2 new
    #old    *                   *                       empty
    #old    new                 new
    global me

    def true(x, y):
      return True

    def hasYES(x, y):
      return "YES" in x

    me.cur = me.conn.cursor()
    #me.cur = me.conn.cursor(cursor_factory=psy.LoggingCursor)
    #me.cur.setLogger(me.fileLogger)

    psy.execute(me.cur, "delete from bug_status")
    me.cur.connection.commit()

    # test intial insert
    sample1 = [ (2,"CLOSED","WONTFIX","a short desc",set(["aaaa"])),
                (3,"NEW","","a short desc",set([])),
                (343324,"ASSIGNED","","a short desc",set(["bbbb","cccc"])),
                (343325,"CLOSED","RESOLVED","a short desc",set(["dddd"])),
              ]
    correct1 = { "bugs": [(2,     "CLOSED",  "WONTFIX", "a short desc"),
                          (343324,"ASSIGNED","",        "a short desc"),
#.........这里部分代码省略.........
开发者ID:AlinT,项目名称:socorro,代码行数:103,代码来源:testBugzilla.py

示例5: TestBuilds

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
class TestBuilds(unittest.TestCase):
  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)


  def tearDown(self):
    self.logger.clear()


  def do_nightlyBuildExists(self, d, correct):
    me.cur = me.conn.cursor(cursor_factory=psy.LoggingCursor)
    me.cur.setLogger(me.fileLogger)

    actual = builds.nightlyBuildExists(me.cur, d[0], d[1], d[2], d[3])
    assert actual == correct, "expected %s, got %s " % (correct, actual)

  def do_releaseBuildExists(self, d, correct):
    me.cur = me.conn.cursor(cursor_factory=psy.LoggingCursor)
    me.cur.setLogger(me.fileLogger)

    actual = builds.releaseBuildExists(me.cur, d[0], d[1], d[2], d[3], d[4], d[5])
    assert actual == correct, "expected %s, got %s " % (correct, actual)

  def test_buildExists(self):
    d = ( "failfailfail", "VERSIONAME1", "PLATFORMNAME1", "1" )
    self.do_nightlyBuildExists(d, False)
    d = ( "PRODUCTNAME1", "VERSIONAME1", "PLATFORMNAME1", "1" )
    self.do_nightlyBuildExists(d, True)

    d = ( "failfailfail", "VERSIONAME1", "1", "BUILDTYPE1", "PLATFORMNAME1", "1" )
    self.do_releaseBuildExists(d, False)
    r = ( "PRODUCTNAME1", "VERSIONAME1", "1", "BUILDTYPE1", "PLATFORMNAME1", "1" )
    self.do_releaseBuildExists(r, True)


  def test_fetchBuild(self):
    fake_response_contents_1 = '11111'
    fake_response_contents_2 = '22222'
    fake_response_contents = '%s %s' % (fake_response_contents_1, fake_response_contents_2)
    fake_urllib2_url = 'http://www.example.com/'
    self.config.base_url = fake_urllib2_url

    fakeResponse = exp.DummyObjectWithExpectations()
    fakeResponse.code = 200
    fakeResponse.expect('read', (), {}, fake_response_contents)
    fakeResponse.expect('close', (), {})

    fakeUrllib2 = exp.DummyObjectWithExpectations()
    fakeUrllib2.expect('urlopen', (fake_urllib2_url,), {}, fakeResponse)

    try:
      actual = builds.fetchBuild(fake_urllib2_url, fakeUrllib2)
      assert actual[0] == fake_response_contents_1, "expected %s, got %s " % (fake_response_contents_1, actual)
      assert actual[1] == fake_response_contents_2, "expected %s, got %s " % (fake_response_contents_2, actual)

    except Exception, x:
      print "Exception in test_fetchBuild() ... Error: ",type(x),x
      socorro.lib.util.reportExceptionAndAbort(me.fileLogger)
开发者ID:AlinT,项目名称:socorro,代码行数:76,代码来源:testBuilds.py

示例6: TestFtpScraper

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
class TestFtpScraper(unittest.TestCase):
    def setUp(self):
        global me
        self.config = cfgManager.newConfiguration(
              configurationModule=testConfig,
              applicationName='Testing ftpscraper')

        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 = cfgManager.Config([('t', 'testPath',
                                              True, './TEST-BUILDS', ''),
                                             ('f', 'testFileName',
                                              True, 'lastrun.pickle', '')])
        self.testConfig["persistentDataPathname"] = os.path.join(
              self.testConfig.testPath, self.testConfig.testFileName)

    def tearDown(self):
        self.logger.clear()

    def test_getLinks(self):
        self.config.products = ('PRODUCT1', 'PRODUCT2')
        self.config.base_url = 'http://www.example.com/'

        fake_response_url = "%s%s" % (self.config.base_url,
              self.config.products[0])
        fake_response_contents = """
             blahblahblahblahblah
             <a href="product1-v1.en-US.p1.txt">product1-v1.en-US.p1.txt</a>
             <a href="product1-v1.en-US.p1.zip">product1-v1.en-US.p1.zip</a>
             <a href="product2-v2.en-US.p2.txt">product2-v2.en-US.p2.txt</a>
             <a href="product2-v2.en-US.p2.zip">product2-v2.en-US.p2.zip</a>
             blahblahblahblahblah
        """

        fakeResponse = exp.DummyObjectWithExpectations()
        fakeResponse.code = 200
        fakeResponse.expect('read', (), {}, fake_response_contents)
        fakeResponse.expect('close', (), {})

        fakeUrllib2 = exp.DummyObjectWithExpectations()
        fakeUrllib2.expect('urlopen', (fake_response_url,), {}, fakeResponse)

        actual = ftpscraper.getLinks('http://www.example.com/PRODUCT1',
            startswith='product1', urllib=fakeUrllib2)
        expected = ['product1-v1.en-US.p1.txt',
                    'product1-v1.en-US.p1.zip']
        assert actual == expected, "expected %s, got %s" % (expected, actual)

        fakeResponse = exp.DummyObjectWithExpectations()
        fakeResponse.code = 200
        fakeResponse.expect('read', (), {}, fake_response_contents)
        fakeResponse.expect('close', (), {})

        fakeUrllib2 = exp.DummyObjectWithExpectations()
        fakeUrllib2.expect('urlopen', (fake_response_url,), {}, fakeResponse)

        expected = ['product1-v1.en-US.p1.zip',
                    'product2-v2.en-US.p2.zip']
        actual = ftpscraper.getLinks('http://www.example.com/PRODUCT1',
              endswith='.zip', urllib=fakeUrllib2)
        assert actual == expected, "expected %s, got %s" % (expected, actual)

    def test_parseInfoFile(self):
        self.config.products = ('PRODUCT1', 'PRODUCT2')
        self.config.base_url = 'http://www.example.com/'

        fake_response_url = "%s%s" % (self.config.base_url,
              self.config.products[0])
        fake_response_contents = """
            20111011042016
            http://hg.mozilla.org/releases/mozilla-aurora/rev/327f5fdae663
        """

        fakeResponse = exp.DummyObjectWithExpectations()
        fakeResponse.code = 200
        fakeResponse.expect('read', (), {}, fake_response_contents)
        fakeResponse.expect('close', (), {})

        fakeUrllib2 = exp.DummyObjectWithExpectations()
        fakeUrllib2.expect('urlopen', (fake_response_url,), {}, fakeResponse)

        rev = 'http://hg.mozilla.org/releases/mozilla-aurora/rev/327f5fdae663'
        expected = {
          'buildID': '20111011042016',
          'rev': rev
        }
        actual = ftpscraper.parseInfoFile('http://www.example.com/PRODUCT1',
              nightly=True, urllib=fakeUrllib2)
        assert actual == expected, "expected %s, got %s" % (expected, actual)

        fake_response_contents = """
#.........这里部分代码省略.........
开发者ID:Meghashyamt,项目名称:socorro,代码行数:103,代码来源:testFtpScraper.py

示例7: TestMtbf

# 需要导入模块: from socorro.unittest.testlib.loggerForTest import TestingLogger [as 别名]
# 或者: from socorro.unittest.testlib.loggerForTest.TestingLogger import clear [as 别名]
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,代码行数:103,代码来源:testMtbf.py


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