call site 0 for compat.doctest.DocTestRunner.run
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
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 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 
/tmp/pytest-0/docdoctest/conftest.py - line 131
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
   def run(self): 
       # XXX quite nasty... but it works (fixes win32 issues)
       s = self._normalize_linesep()
       l = []
       prefix = '.. >>> '
       mod = py.std.types.ModuleType(self.fspath.purebasename) 
       for line in deindent(s).split('\n'):
           stripped = line.strip()
           if stripped.startswith(prefix):
               exec py.code.Source(stripped[len(prefix):]).compile() in \
                    mod.__dict__
               line = ""
           else:
               l.append(line)
       docstring = "\n".join(l)
->     self.execute(mod, docstring)
/tmp/pytest-0/docdoctest/conftest.py - line 135
133
134
135
136
137
138
   def execute(self, mod, docstring): 
       mod.__doc__ = docstring 
->     failed, tot = py.compat.doctest.testmod(mod, verbose=1)
       if failed: 
           py.test.fail("doctest %s: %s failed out of %s" %(
                        self.fspath, failed, tot))
compat/doctest.py - line 1847
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
   def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
               report=True, optionflags=0, extraglobs=None,
               raise_on_error=False, exclude_empty=False):
       """m=None, name=None, globs=None, verbose=None, isprivate=None,
          report=True, optionflags=0, extraglobs=None, raise_on_error=False,
          exclude_empty=False
   
       Test examples in docstrings in functions and classes reachable
       from module m (or the current module if m is not supplied), starting
       with m.__doc__.  Unless isprivate is specified, private names
       are not skipped.
   
       Also test examples reachable from dict m.__test__ if it exists and is
       not None.  m.__test__ maps names to functions, classes and strings;
       function and class docstrings are tested even if the name is private;
       strings are tested directly, as if they were docstrings.
   
       Return (#failures, #tests).
   
       See doctest.__doc__ for an overview.
   
       Optional keyword arg "name" gives the name of the module; by default
       use m.__name__.
   
       Optional keyword arg "globs" gives a dict to be used as the globals
       when executing examples; by default, use m.__dict__.  A copy of this
       dict is actually used for each docstring, so that each docstring's
       examples start with a clean slate.
   
       Optional keyword arg "extraglobs" gives a dictionary that should be
       merged into the globals that are used to execute examples.  By
       default, no extra globals are used.  This is new in 2.4.
   
       Optional keyword arg "verbose" prints lots of stuff if true, prints
       only failures if false; by default, it's true iff "-v" is in sys.argv.
   
       Optional keyword arg "report" prints a summary at the end when true,
       else prints nothing at the end.  In verbose mode, the summary is
       detailed, else very brief (in fact, empty if all tests passed).
   
       Optional keyword arg "optionflags" or's together module constants,
       and defaults to 0.  This is new in 2.3.  Possible values (see the
       docs for details):
   
           DONT_ACCEPT_TRUE_FOR_1
           DONT_ACCEPT_BLANKLINE
           NORMALIZE_WHITESPACE
           ELLIPSIS
           IGNORE_EXCEPTION_DETAIL
           REPORT_UDIFF
           REPORT_CDIFF
           REPORT_NDIFF
           REPORT_ONLY_FIRST_FAILURE
   
       Optional keyword arg "raise_on_error" raises an exception on the
       first unexpected exception or failure. This allows failures to be
       post-mortem debugged.
   
       Deprecated in Python 2.4:
       Optional keyword arg "isprivate" specifies a function used to
       determine whether a name is private.  The default function is
       treat all functions as public.  Optionally, "isprivate" can be
       set to doctest.is_private to skip over functions marked as private
       using the underscore naming convention; see its docs for details.
   
       Advanced tomfoolery:  testmod runs methods of a local instance of
       class doctest.Tester, then merges the results into (or creates)
       global Tester instance doctest.master.  Methods of doctest.master
       can be called directly too, if you want to do something unusual.
       Passing report=0 to testmod is especially useful then, to delay
       displaying a summary.  Invoke doctest.master.summarize(verbose)
       when you're done fiddling.
       """
       global master
   
       if isprivate is not None:
           warnings.warn("the isprivate argument is deprecated; "
                         "examine DocTestFinder.find() lists instead",
                         DeprecationWarning)
   
       # If no module was given, then use __main__.
       if m is None:
           # DWA - m will still be None if this wasn't invoked from the command
           # line, in which case the following TypeError is about as good an error
           # as we should expect
           m = sys.modules.get('__main__')
   
       # Check that we were actually given a module.
       if not inspect.ismodule(m):
           raise TypeError("testmod: module required; %r" % (m,))
   
       # If no name was given, then use the module's name.
       if name is None:
           name = m.__name__
   
       # Find, parse, and run all tests in the given module.
       finder = DocTestFinder(_namefilter=isprivate, exclude_empty=exclude_empty)
   
       if raise_on_error:
           runner = DebugRunner(verbose=verbose, optionflags=optionflags)
       else:
           runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
   
       for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
->         runner.run(test)
   
       if report:
           runner.summarize()
   
       if master is None:
           master = runner
       else:
           master.merge(runner)
   
       return runner.failures, runner.tries