call site 0 for code.Source.deindent
doc/example/pytest/test_failures.py - line 9
6
7
8
9
10
11
12
13
   def test_failure_demo_fails_properly(): 
       config = py.test.config._reparse([failure_demo]) 
       session = config.initsession()
->     session.main()
       l = session.getitemoutcomepairs(Failed)
       assert len(l) == 21 
       l = session.getitemoutcomepairs(Passed)
       assert not l 
test/session.py - line 63
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
   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
       return self.getitemoutcomepairs(Failed)
test/session.py - line 84
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
100
   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 119
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
   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 84
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
100
   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 119
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
   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 84
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
100
   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 119
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
   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 84
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
100
   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 107
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
   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/item.py - line 64
61
62
63
64
   def run(self):
       """ setup and execute the underlying test function. """
       self._state.prepare(self) 
->     self.execute(self.obj, *self._args)
test/item.py - line 68
66
67
68
   def execute(self, target, *args):
       """ execute the given test function. """
->     target(*args)
doc/example/pytest/failure_demo.py - line 21
15
16
17
18
19
20
21
   def test_simple(self):
       def f():
           return 42
       def g():
           return 43
   
->     assert f() == g()
magic/assertion.py - line 15
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
   def __init__(self, *args):
       BuiltinAssertionError.__init__(self, *args)
       if args: 
           self.msg = str(args[0])
       else: 
           f = sys._getframe(1)
           try:
->             source = py.code.Frame(f).statement
               source = str(source.deindent()).strip()
           except py.error.ENOENT:
               source = None
               # this can also occur during reinterpretation, when the
               # co_filename is set to "<run>".
           if source:
               self.msg = exprinfo.interpret(source, f, should_fail=True)
               if not self.args:
                   self.args = (self.msg,)
           else:
               self.msg = None
code/frame.py - line 16
15
16
   def statement(self):
->     return self.code.fullsource.getstatement(self.lineno)
code/source.py - line 95
91
92
93
94
95
96
   def getstatement(self, lineno):
       """ return Source statement which contains the
               given linenumber (counted from 0).
           """
->     start, end = self.getstatementrange(lineno)
       return self[start:end]
code/source.py - line 125
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
   def getstatementrange(self, lineno):
       """ return (start, end) tuple which spans the minimal 
               statement region which containing the given lineno.
           """
       # XXX there must be a better than these heuristic ways ...
       # XXX there may even be better heuristics :-)
       if not (0 <= lineno < len(self)):
           raise IndexError("lineno out of range")
   
       # 1. find the start of the statement
       from codeop import compile_command
       for start in range(lineno, -1, -1):
           trylines = self.lines[start:lineno+1]
           # quick hack to indent the source and get it as a string in one go
           trylines.insert(0, 'def xxx():')
           trysource = '\n '.join(trylines)
           #              ^ space here
           try:
               compile_command(trysource)
           except (SyntaxError, OverflowError, ValueError):
               pass
           else:
               break   # got a valid or incomplete statement
   
       # 2. find the end of the statement
       for end in range(lineno+1, len(self)+1):
           trysource = self[start:end]
->         if trysource.isparseable():
               break
   
       return start, end
code/source.py - line 156
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
   def isparseable(self, deindent=True):
       """ return True if source is parseable, heuristically
               deindenting it by default. 
           """
       import parser
       if deindent:
->         source = str(self.deindent())
       else:
           source = str(self)
       try:
           parser.suite(source+'\n')
       except (parser.ParserError, SyntaxError):
           return False
       else:
           return True