call site 0 for test.collect.Instance.classnamefilter
test/testing/test_session.py - line 92
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
   def test_select_extra_keywords(self): 
       o = tmpdir.ensure('selecttest', dir=1)
       tfile = o.join('test_select.py').write(py.code.Source("""
               def test_1():
                   pass 
               class TestClass: 
                   def test_2(self): 
                       pass
           """))
       conftest = o.join('conftest.py').write(py.code.Source("""
               import py
               class Class(py.test.collect.Class): 
                   def _haskeyword(self, keyword): 
                       return keyword == 'xxx' or \
                              super(Class, self)._haskeyword(keyword) 
           """))
       for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1', 
                       'TestClass test_2', 'xxx TestClass test_2',): 
           f = py.std.StringIO.StringIO()
           config = py.test.config._reparse([o, '-k', keyword]) 
           session = config._getsessionclass()(config, f) 
->         session.main()
           print "keyword", repr(keyword)
           l = session.getitemoutcomepairs(Passed)
           assert len(l) == 1
           assert l[0][0].name == 'test_2'
           l = session.getitemoutcomepairs(Skipped)
           assert l[0][0].name == 'test_1' 
test/session.py - line 63
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
   def main(self): 
       """ main loop for running tests. """
       colitems = self.config.getcolitems()
       try:
           self.header(colitems) 
           try:
               try:
                   for colitem in colitems: 
->                     self.runtraced(colitem)
               except KeyboardInterrupt: 
                   raise 
           finally: 
               self.footer(colitems) 
       except Exit, ex:
           pass
test/session.py - line 83
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
   def runtraced(self, colitem):
       if self.shouldclose(): 
           raise Exit, "received external close signal" 
   
       outcome = None 
       colitem.startcapture() 
       try: 
           self.start(colitem)
           try: 
               try:
                   if colitem._stickyfailure: 
                       raise colitem._stickyfailure 
->                 outcome = self.run(colitem) 
               except (KeyboardInterrupt, Exit): 
                   raise 
               except Outcome, outcome: 
                   if outcome.excinfo is None: 
                       outcome.excinfo = py.code.ExceptionInfo() 
               except: 
                   excinfo = py.code.ExceptionInfo() 
                   outcome = Failed(excinfo=excinfo) 
               assert (outcome is None or 
                       isinstance(outcome, (list, Outcome)))
           finally: 
               self.finish(colitem, outcome) 
           if isinstance(outcome, Failed) and self.config.option.exitfirst:
               py.test.exit("exit on first problem configured.", item=colitem)
       finally: 
           colitem.finishcapture()
test/session.py - line 118
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
   def run(self, colitem): 
       if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): 
           return 
       if isinstance(colitem, py.test.collect.Item): 
           colitem._skipbykeyword(self.config.option.keyword)
       res = colitem.run() 
       if res is None: 
           return Passed() 
       elif not isinstance(res, (list, tuple)): 
           raise TypeError("%r.run() returned neither "
                           "list, tuple nor None: %r" % (colitem, res))
       else: 
           finish = self.startiteration(colitem, res)
           try: 
               for name in res: 
                   obj = colitem.join(name) 
                   assert obj is not None 
->                 self.runtraced(obj) 
           finally: 
               if finish: 
                   finish() 
       return res 
test/session.py - line 83
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
   def runtraced(self, colitem):
       if self.shouldclose(): 
           raise Exit, "received external close signal" 
   
       outcome = None 
       colitem.startcapture() 
       try: 
           self.start(colitem)
           try: 
               try:
                   if colitem._stickyfailure: 
                       raise colitem._stickyfailure 
->                 outcome = self.run(colitem) 
               except (KeyboardInterrupt, Exit): 
                   raise 
               except Outcome, outcome: 
                   if outcome.excinfo is None: 
                       outcome.excinfo = py.code.ExceptionInfo() 
               except: 
                   excinfo = py.code.ExceptionInfo() 
                   outcome = Failed(excinfo=excinfo) 
               assert (outcome is None or 
                       isinstance(outcome, (list, Outcome)))
           finally: 
               self.finish(colitem, outcome) 
           if isinstance(outcome, Failed) and self.config.option.exitfirst:
               py.test.exit("exit on first problem configured.", item=colitem)
       finally: 
           colitem.finishcapture()
test/session.py - line 113
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
   def run(self, colitem): 
       if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): 
           return 
       if isinstance(colitem, py.test.collect.Item): 
           colitem._skipbykeyword(self.config.option.keyword)
       res = colitem.run() 
       if res is None: 
           return Passed() 
       elif not isinstance(res, (list, tuple)): 
           raise TypeError("%r.run() returned neither "
                           "list, tuple nor None: %r" % (colitem, res))
       else: 
->         finish = self.startiteration(colitem, res)
           try: 
               for name in res: 
                   obj = colitem.join(name) 
                   assert obj is not None 
                   self.runtraced(obj) 
           finally: 
               if finish: 
                   finish() 
       return res 
test/terminal/terminal.py - line 67
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
   def startiteration(self, colitem, subitems): 
       if (isinstance(colitem, py.test.collect.Module) 
           and self.config.option.verbose == 0 
           and not self.config.option.collectonly): 
           try: 
               sum = 0
               for sub in subitems:
->                 sum += len(list(colitem.join(sub)._tryiter()))
           except (SystemExit, KeyboardInterrupt): 
               raise 
           except: 
               self.out.write('[?]')
           else: 
               self.out.write('[%d] ' % sum) 
           return self.out.line 
test/collect.py - line 217
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
   def _tryiter(self, yieldtype=None, reporterror=None, keyword=None):
       """ yield stop item instances from flattening the collector. 
               XXX deprecated: this way of iteration is not safe in all
               cases. 
           """ 
       if yieldtype is None: 
           yieldtype = py.test.collect.Item 
       if isinstance(self, yieldtype):
           try:
               self._skipbykeyword(keyword)
               yield self
           except Skipped:
               if reporterror is not None:
                   excinfo = py.code.ExceptionInfo()
                   reporterror((excinfo, self))
       else:
           if not isinstance(self, py.test.collect.Item):
               try:
                   if reporterror is not None:
                       reporterror((None, self))
                   for x in self.run(): 
                       for y in self.join(x)._tryiter(yieldtype, 
->                                         reporterror, keyword): 
                           yield y
               except KeyboardInterrupt:
                   raise
               except: 
                   if reporterror is not None: 
                       excinfo = py.code.ExceptionInfo()
                       reporterror((excinfo, self)) 
test/collect.py - line 215
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
   def _tryiter(self, yieldtype=None, reporterror=None, keyword=None):
       """ yield stop item instances from flattening the collector. 
               XXX deprecated: this way of iteration is not safe in all
               cases. 
           """ 
       if yieldtype is None: 
           yieldtype = py.test.collect.Item 
       if isinstance(self, yieldtype):
           try:
               self._skipbykeyword(keyword)
               yield self
           except Skipped:
               if reporterror is not None:
                   excinfo = py.code.ExceptionInfo()
                   reporterror((excinfo, self))
       else:
           if not isinstance(self, py.test.collect.Item):
               try:
                   if reporterror is not None:
                       reporterror((None, self))
->                 for x in self.run(): 
                       for y in self.join(x)._tryiter(yieldtype, 
                                           reporterror, keyword): 
                           yield y
               except KeyboardInterrupt:
                   raise
               except: 
                   if reporterror is not None: 
                       excinfo = py.code.ExceptionInfo()
                       reporterror((excinfo, self)) 
test/collect.py - line 339
338
339
340
341
342
   def run(self): 
->     self._prepare()
       itemlist = self._name2items.values()
       itemlist.sort()
       return [x.name for x in itemlist]
test/collect.py - line 331
325
326
327
328
329
330
331
332
333
334
335
336
   def _prepare(self): 
       if not hasattr(self, '_name2items'): 
           ex = getattr(self, '_name2items_exception', None)
           if ex is not None: 
               raise ex[0], ex[1], ex[2]
           try: 
->             self._name2items = self._buildname2items()
           except (SystemExit, KeyboardInterrupt): 
               raise 
           except:
               self._name2items_exception = py.std.sys.exc_info()
               raise 
test/collect.py - line 310
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
   def _buildname2items(self): 
       # NB. we avoid random getattrs and peek in the __dict__ instead
       d = {}
       dicts = [getattr(self.obj, '__dict__', {})]
       for basecls in py.std.inspect.getmro(self.obj.__class__):
           dicts.append(basecls.__dict__)
       seen = {}
       for dic in dicts:
           for name, obj in dic.items():
               if name in seen:
                   continue
               seen[name] = True
->             res = self.makeitem(name, obj)
               if res is not None:
                   d[name] = res 
       return d
test/collect.py - line 316
315
316
317
318
319
320
321
322
323
   def makeitem(self, name, obj, usefilters=True):
->     if (not usefilters or self.classnamefilter(name)) and \
           py.std.inspect.isclass(obj):
           return self.Class(name, parent=self)
       elif (not usefilters or self.funcnamefilter(name)) and callable(obj): 
           if obj.func_code.co_flags & 32: # generator function 
               return self.Generator(name, parent=self)
           else: 
               return self.Function(name, parent=self)