call site 0 for io.FDCapture.setasfile
doc/test_conftest.py - line 48
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
   def test_doctest_basic(): 
       # XXX get rid of the next line: 
       py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
   
       xtxt = tmpdir.join('x.txt')
       xtxt.write(py.code.Source("""
           .. 
              >>> from os.path import abspath 
   
           hello world 
   
              >>> assert abspath 
              >>> i=3
              >>> print i
              3
   
           yes yes
   
               >>> i
               3
   
           end
       """))
       config = py.test.config._reparse([xtxt]) 
       session = config.initsession()
->     session.main()
       l = session.getitemoutcomepairs(Failed)
       assert len(l) == 0 
       l = session.getitemoutcomepairs(Passed)
       l2 = session.getitemoutcomepairs(Skipped)
       assert len(l+l2) == 2
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 76
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/collect.py - line 364
363
364
   def startcapture(self): 
->     self._config._startcapture(self, path=self.fspath)
test/config.py - line 258
253
254
255
256
257
258
259
260
261
262
263
   def _startcapture(self, colitem, path=None):
       if not self.option.nocapture:
           assert not hasattr(colitem, '_capture')
           iocapture = self.getvalue("conf_iocapture", path=path)
           if iocapture == "fd": 
->             capture = py.io.StdCaptureFD()
           elif iocapture == "sys":
               capture = py.io.StdCapture()
           else:
               raise ValueError("unknown io capturing: " + iocapture)
           colitem._capture = capture
io/stdcapture.py - line 49
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
   def __init__(self, out=True, err=True, mixed=False, in_=True, patchsys=True): 
       if in_:
           self._oldin = (sys.stdin, os.dup(0))
           sys.stdin  = DontReadFromInput()
           fd = os.open(devnullpath, os.O_RDONLY)
           os.dup2(fd, 0)
           os.close(fd)
       if out: 
           self.out = py.io.FDCapture(1) 
           if patchsys: 
->             self.out.setasfile('stdout')
       if err: 
           if mixed and out:
               tmpfile = self.out.tmpfile 
           else:
               tmpfile = None    
           self.err = py.io.FDCapture(2, tmpfile=tmpfile) 
           if patchsys: 
               self.err.setasfile('stderr')